Note that there are some explanatory texts on larger screens.

plurals
  1. POtable just inserts one row. there is an auto increment id
    text
    copied!<p>This is my registration code.</p> <p>Once I enter the fields in the form it shows me registration successful but adds blank data in my database table. It adds number 0 in my mobileno column.</p> <p>Please help me here asap</p> <p> <pre><code>include ('database_connection.php'); if (isset($_POST['formsubmitted'])) { $error = array();//Declare An Array to store any error message if (empty($_POST['mobileno'])) {//if no name has been supplied $error[] = 'Please Enter a Mobile Number ';//add to array "error" } else { $name = $_POST['mobileno'];//else assign it a variable } if (empty($_POST['fname'])) {//if no name has been supplied $error[] = 'Please Enter a First name ';//add to array "error" } else { $name = $_POST['fname'];//else assign it a variable } if (empty($_POST['lname'])) {//if no name has been supplied $error[] = 'Please Enter a Last name ';//add to array "error" } else { $name = $_POST['lname'];//else assign it a variable } if (empty($_POST['email'])) { $error[] = 'Please Enter your Email '; } else { if (preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA- Z0-9\._-]+)+$/", $_POST['email'])) { //regular expression for email validation $Email = $_POST['email']; } else { $error[] = 'Your EMail Address is invalid '; } } if (empty($_POST['passwd1'])) { $error[] = 'Please Enter Your Password '; } else { $Password = $_POST['passwd1']; } if (empty($_POST['passwd2'])) { $error[] = 'Please Verify Your Password '; } else { $Password = $_POST['passwd2']; } if (empty($error)) //send to Database if there's no error ' { //If everything's OK... // Make sure the mobile no is available: $query_verify_mobileno = "SELECT * FROM userdtls WHERE mobileno = '$mobileno'"; $result_verify_mobileno = mysqli_query($dbc, $query_verify_mobileno); if (!$result_verify_mobileno) {//if the Query Failed ,similar to if($result_verify_mobileno==false) echo ' Database Error Occured '; } if (mysqli_num_rows($result_verify_mobileno) == 0) { // IF no previous user is using this number . // Create a unique activation code: $activation = md5(uniqid(rand(), true)); $query_insert_user = "INSERT INTO userdtls (`mobileno`, `pass`, `fname`, `lname`, `email`, `activation`) VALUES ( '$mobileno', '$passwd1', '$fname', '$lname', '$email', '$activation')"; $result_insert_user = mysqli_query($dbc, $query_insert_user); if (!$result_insert_user) { echo 'Query Failed '; } if (mysqli_affected_rows($dbc) == 1) { //If the Insert Query was successfull. // Send the email: $message = " To activate your account, please click on this link:\n\n"; $message .= WEBSITE_URL . '/activate.php?email=' . urlencode($Email) . "&amp;key=$activation"; mail($Email, 'Registration Confirmation', $message, 'From: rahul19dj@gmail.com'); // Flush the buffered output. // Finish the page: echo '&lt;div class="success"&gt;Thank you for registering! A confirmation email has been sent to '.$email.' Please click on the Activation Link to Activate your account &lt;/div&gt;'; } else { // If it did not run OK. echo '&lt;div class="errormsgbox"&gt;You could not be registered due to a system error. We apologize for any inconvenience.&lt;/div&gt;'; } } else { // The mobile number is not available. echo '&lt;div class="errormsgbox" &gt;That mobile number has already been registered.&lt;/div&gt;'; } } else {//If the "error" array contains error msg , display them echo '&lt;div class="errormsgbox"&gt; &lt;ol&gt;'; foreach ($error as $key =&gt; $values) { echo ' &lt;li&gt;'.$values.'&lt;/li&gt;'; } echo '&lt;/ol&gt;&lt;/div&gt;'; } mysqli_close($dbc);//Close the DB Connection } // End of the main Submit conditional. </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