I have previously written a question similar to this before hand and I have seemed to fix only minor errors in my code but like most of the time, when I fix one thing, another arises.
Before I clarify my problem, I just want to explain the background. Basically have two registration forms, both are used one after the other with their own input devices and validations. When I input the data in the first registration form, I press next and it takes me to the second form where I must fill out other information before I "register" completely. In my second registration form, I used a list of hidden inputs, like <input type="hidden" name="name" value="<?php echo $_POST['name'];?>"/>
so that I can hold the information from first registration file and still possess the same data without loosing it completely when I am taken to the next registration page.
Below is my code:
<?php
if (isset($_POST['submit'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$name = $_POST['name'];
$lname = $_POST['lname'];
$address = $_POST['address'];
$agreement= $_POST['agreement'];
$conditions= $_POST['conditions'];
}
$conn = mysql_connect("localhost", "*****", "******");
mysql_select_db("*********", $conn)
or die ('Database not found ' . mysql_error() );
$sql= "INSERT INTO `users` (username, password, name, lname, address, agreement, conditions)
VALUES (". $username .", ". $password .", ". $name .", ". $lname .", ". $address .", ". $agreement .", ". $conditions.")";
$rs = mysql_query($sql, $conn)
or die ('Problem with query' . mysql_error());
mysql_close($conn)
?>
My form opens but I get a list of errors
Notice: Undefined variable: username ... at line 140
.
Line 140 meaning the VALUES
line with my variables.
All I can say at the moment is that I know I am using the correct database and table, which is why this is extremely confusing for me as to why the data I input is not inserting into the database. I have tried many methods and nothing have helped improve my code so far.