Note that there are some explanatory texts on larger screens.

plurals
  1. POSome values are not showing up in mySQL database
    primarykey
    data
    text
    <p>I'm using phpMyAdmin to store a database. The problem is when I make the <strong>insert</strong> query only 3 fields are fullfilled and 2 of them are ignored. </p> <p><img src="https://i.stack.imgur.com/6z5jM.png" alt="enter image description here"></p> <p>Yes, I have read other answer but no luck so far. If I add customers manually the name and surname shows up there. I deleted those I've inserted manually, so there is no c_id 3 and 4 in table. </p> <p>This is the code for registration.php:</p> <pre><code> &lt;?php if(isset($_GET['error'])) echo $_GET['error']; ?&gt; &lt;form action = "register.php" method = "POST"&gt; &lt;label&gt;Password: &lt;input type = "password" name = "password"&gt; &lt;label/&gt; &lt;br/&gt; &lt;label&gt;Confirm password: &lt;input type = "password" name = "password_again"&gt; &lt;label/&gt;&lt;br/&gt; &lt;label&gt;First name: &lt;input type = "text" name = "fname"&gt; &lt;label/&gt;&lt;br/&gt; &lt;label&gt;Last name: &lt;input type = "text" name = "lname"&gt; &lt;label/&gt;&lt;br/&gt; &lt;label&gt;Address: &lt;input type = "text" name = "address"&gt; &lt;label/&gt;&lt;br/&gt; &lt;input type = "submit" name = "register" value = "Register"/&gt;&lt;br/&gt; &lt;/form&gt; </code></pre> <p>register.php: </p> <pre><code>&lt;?php if(isset($_POST['register'])) { require "db.php"; $password =md5(strip_tags($_POST['password'])); $password_again = md5(strip_tags($_POST['password_again'])); $firstname = strip_tags($_POST['fname']); $lastname = strip_tags($_POST['lname']); #$firstname = $_POST['firstname']; #$lastname = $_POST['lastname']; $address = strip_tags($_POST['address']); /*echo $firstname; echo $lastname;*/ if($password == '' || $password_again == '' || $firstname = '' || $lastname = '' || $address == '') { header('location:./registerform.php?error=empty fields'); exit(); } if(!strcmp($password, $password_again)==0) { header('location:./registerform.php?error=passwords not matching'); exit(); } $sql = "INSERT INTO customers VALUES (NULL, '$password', '$firstname', '$lastname', '$address')"; mysql_query($sql); #mysql_query("INSERT INTO customers(C_ID, C_PWD, C_FNAME, C_LNAME, C_ADD) VALUES(NULL, '$password', '$firstname', '$lastname', '$address')") or die("".mysql_error()); #echo $firstname; #echp $lastname; echo "Registered. Please login with your ID ".mysql_insert_id(). "."; echo "&lt;br/&gt;&lt;a href = 'loginform.php'&gt;Login here&lt;/a&gt;"; } else { header('location:registration.php'); exit(); } ?&gt; </code></pre> <p>db.php code:</p> <pre><code>&lt;?php $name = "root"; $pas = ""; $dbname = "webstore"; $connection = mysql_connect("localhost", $name, $pas) or die ("Could not connect"); $selection = mysql_select_db($dbname, $connection) or die ("Could not select the db"); ?&gt; </code></pre> <p>For the dubugging purposes I've tried to print $firstname and $lastname, they're printed when they're retrieved from the form but nothing prints if it is after query. Any suggestions? Thanks in advance </p>
    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