Note that there are some explanatory texts on larger screens.

plurals
  1. POTrouble inserting PHP variables into Mysqli
    primarykey
    data
    text
    <p>I am trying to insert data from a form I have made into my MYsql table using mysqli but whenever I submit my form it just displays the successfully connected to db server. Any ideas? It should show my errors for the insert shouldn't it?</p> <pre><code>&lt;?php if ($_POST['submit']) { $errormsg = ""; $name = $_POST['name']; $password = $_POST['password']; $password2 = $_POST['password2']; $email = $_POST['email']; $phone = $_POST['phone']; $connection = @mysqli_connect("$hostname","$username", "$password", "$database"); if(!$connection){ die("&lt;p&gt;The database server is not available.&lt;/p&gt;".mysqli_error()); } echo "&lt;p&gt;Sucessfully connected to the database server.&lt;/p&gt;"; if((!$name)||(!$password)||(!$password2)||(!$email)||(!$phone)){ /* Checks if all inputs are filled*/ $errormsg = "Please insert the required fields below&lt;br /&gt;"; if ($name == "") { $errormsg = $errormsg . "Enter a name.&lt;br /&gt;"; } if ($password == "") { $errormsg = $errormsg . "Please enter a password.&lt;br /&gt;"; } if ($password2 =="") { $errormsg = $errormsg . "Please re-enter your password.&lt;br /&gt;"; } if ($email =="") { $errormsg = $errormsg . "Please enter an email address.&lt;br /&gt;"; } if ($phone =="") { $errormsg = $errormsg . "Please enter a phone number.&lt;br /&gt;"; } if($errormsg){ echo "$errormsg"; } } if($password != $password2) { $errormsg = $errormsg. "Your passwords must match!&lt;br/&gt;"; } function checkEmail($email){ //begin email check function $sql = "SELECT count(email) FROM CUSTOMER WHERE email='$email'"; $result = mysqli_result(mysqli_query($sql),0); if( $result &gt; 0 ){ $errormsg = $errormsg. "There is already a user with that email!"; }//end email check function if(!$errormsg) { $insertquery = "INSERT INTO CUSTOMER (customer_no, name, password, email, phone) VALUES(NULL, '$name', '$password', '$email', '$phone')"; $queryresult = mysqli_query($insertquery); if($queryresult) { echo("&lt;br&gt;Registration sucessful"); } else { echo("&lt;br&gt;registration was not sucessful"); } } } } ?&gt; </code></pre>
    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.
    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