Note that there are some explanatory texts on larger screens.

plurals
  1. PORegistration Page- PHP Error
    text
    copied!<p>I have created a registration page using PHP. The control always goes into else part('Error'). I have defined the database, used the same id used in the form fields but still its the same. I'm unable to figure this out. I'd really appreciate any help.</p> <p>Here's my code : </p> <pre><code>&lt;?php require_once 'connectdb.php'; $dbc = mysqli_connect($mysql_host, $mysql_user , $mysql_pass , $mysql_db ) or die('Error Connecting to database'); if ( isset($_POST['submit'] ) ) { $first_name = mysqli_real_escape_string($dbc, trim($_POST['first_name'])); $last_name = mysqli_real_escape_string($dbc, trim($_POST['last_name'])); $password1 = mysqli_real_escape_string($dbc, trim($_POST['password1'])); $password2 = mysqli_real_escape_string($dbc, trim($_POST['password2'])); $email = mysqli_real_escape_string($dbc, trim($_POST['email'])); if (!empty($first_name) &amp;&amp; !empty($last_name) &amp;&amp; !empty($password1) &amp;&amp; !empty($password2) &amp;&amp; ($password1==$password2) ) { $query = "SELECT * FROM user_db WHERE email='$email'"; $data = mysqli_query($dbc, $query); if(mysqli_num_rows($data) == 0) { $password2 = md5($password1); $query = "INSERT INTO user_db(fname, lname, email, password) VALUES('$first_name','$last_name','$email','$password2')"; $data = mysqli_query($dbc, $query) or die('Error Querying database-Adding info'); echo '&lt;strong&gt;Registration Successful&lt;/strong&gt;'; mysqli_close($dbc); exit(); } else { echo 'An account already exists for with this email id. Kindly use a different one&lt;br /&gt; '; $email = ""; } } else { echo 'Please enter all the fields correctly, including the desired password correctly &lt;br/&gt;'; } } // The control goes everytime into this else part else { echo 'Error'; } mysqli_close($dbc); ?&gt; </code></pre>
 

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