fjw2000 Posted January 27, 2014 Share Posted January 27, 2014 Hey, I am currently reading the book, and have made my own register form and php script. There is no problems with the database connection, but it just will not insert information into the database. The MySQL database is named 'test' and the table 'users'. The table has user_id, first_name, last_name, email, pass and registration_date columns. here is the registration form: <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body><link rel="stylesheet" type="text/css" href="style.css"> <form action="script4.php" method="post"> <p>First Name:<input type="text" name="first_name" /></p> <p>Last Name:<input type="text" name="last_name" /></p> <p>Email: <input type="text" name="email" /></p> <p>Password: <input type="password" name="pass1" /></p> <p>Confirm Password: <input type="password" name="pass2" /></p> <input type="submit" name="submit" value="Submit!" /> </form> </body> </html> and here is script4.php : <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <?php $first_name = $_REQUEST['first_name']; $last_name = $_REQUEST['last_name']; $email = $_REQUEST['email']; $pass1 = $_REQUEST['pass1']; $pass2 = $_REQUEST['pass2']; require ('mysql_connect.php'); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $errors = array();} if (!empty($_POST['first_name'])) { $errors[] = "You forgot to enter your first name!"; } else { $fn = trim($_POST['first_name']); } if (!empty($_POST['last_name'])) { $errors[] = "You forgot to enter your first name!"; } else { $ln = trim($_POST['last_name']); } if (!empty($_POST['email'])) { $errors[] = "You forgot to enter your first name!"; } else { $e = trim($_POST['email']); } if (!empty($_POST['pass1'])) { if ($_POST['pass1'] != $_POST['pass2']) { $errors[] = "Your passwords do not match."; } else { $p = trim($_POST['pass1']);} }else { $errors[] = "You forgot to enter your password."; } if (empty($errors)) { require ('mysql_connect.php'); @mysqli_query("INSERT INTO users (first_name, last_name, email, pass, registration_date) VALUES($first_name, $last_name,$email, SHA1($pass), NOW() )");} ?> </body> </html> Please can someone help me. I am using WAMP server by the way. Link to comment Share on other sites More sharing options...
HartleySan Posted January 27, 2014 Share Posted January 27, 2014 Hello, and welcome to the forums. Have you confirmed that the values stored in the $first_name, $last\Name, $email and $pass variables are what you are expecting? Also, have you tried running a static query on the DB directly to see if that works? 1 Link to comment Share on other sites More sharing options...
Recommended Posts