Note that there are some explanatory texts on larger screens.

plurals
  1. POHeader to Message Page Based On If PHP
    primarykey
    data
    text
    <p>I'm trying to create a page that handles something like existing username. This is what I've got so far .</p> <pre><code>&lt;?php // Parse the form data and add inventory item to the system if (isset($_POST['username'])) { $username = ($_POST['username']); $password = ($_POST['password']); $level = ($_POST['level']); // See if that product name is an identical match to another product in the system $sql = mysql_query("SELECT id FROM users WHERE username='$username' LIMIT 1"); include "storescripts/connect_to_mysql.php"; $productMatch = mysql_num_rows($sql); // count the output amount if ($productMatch &gt; 0) { header("location: message.php?msg=activation_failure"); exit(); } // Add this product into the database now $username = preg_replace('#[^a-z0-9]#i', '', $_POST['username']); $email = mysql_real_escape_string($_POST['email']); $p_hash = md5($password); $sql = mysql_query("INSERT INTO users (username, password, email, level, date_added) VALUES('$username','$p_hash','$email','$level',now())") or die (mysql_error()); header("location: order_complete.php"); exit(); } ?&gt; </code></pre> <p>The if statement queries mysql to determine if there is a match between form entry and database. Then I'd like to go to message.php with a message like ...this username already exists. Any tips on how to do this or how to approach it is greatly appreciated.</p> <p>Further clarification..form starts : </p> <pre><code>&lt;form action="user-info.php" enctype="multipart/form-data" name="signupform" id="signupform" method="post"&gt; </code></pre> <p>and message.php</p> <pre><code>&lt;?php $message = ""; $msg = preg_replace('#[^a-z 0-9.:_()]#i', '', $_GET['msg']); if($msg == "sorryuser"){ $message = 'No good'; } else if($msg == "activation_success"){ $message = 'test'; } else { $message = $msg; } ?&gt; &lt;?php include_once("./includes/site-opener.php");?&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body id="home"&gt; &lt;?php include 'includes/header.php'; ?&gt; &lt;?php include 'includes/content-opener.php'; ?&gt; &lt;div class="containOthers"&gt; &lt;div style="width:300px;margin-left:auto;margin-right:auto;margin-bottom:40px;min-height:500px;"&gt; &lt;div&gt;&lt;?php echo $message; ?&gt;&lt;?php echo $emailError; ?&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;?php include 'includes/footer.php'; ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This is the error on user-info.php after form submission.</p> <blockquote> <p>Warning: mysql_query(): Access denied for user 'onlinfaa'@'localhost' (using password: NO) in /home3/onlinfaa/public_html/user-info.php on line 18 Warning: mysql_query(): A link to the server could not be established in /home3/onlinfaa/public_html/user-info.php on line 18 Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home3/onlinfaa/public_html/user-info.php on line 20 Duplicate entry 'test-email@aol.com' for key 'username'</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload