0

My code:

<?PHP

session_start();
$db = mysqli_connect("127.0.0.1", "root", "root", "Authentication");



if(isset($_POST['sbtn'])){
    session_start();
$f_name = mysql_real_escape_string($_POST['f_name']);
$l_name = mysql_real_escape_string($_POST['l_name']);
$email = mysql_real_escape_string($_POST['email']);
$pass = mysql_real_escape_string($_POST['pass']);
$c_pass = mysql_real_escape_string($_POST['c_pass']);

if($pass == $c_pass){
    //create user
    $pass = md5($pass);
    $sql = "INSERT INTO users(email, password, f_name, l_name) VALUES($email, $pass, $f_name, $l_name)";
    mysqli_query($db, $sql);
    $_SESSION['message'] = "You are now registered welcome to UNDERLINE";
    $_SESSION['name'] = $f_name;
}else{
    //tell user they are not equal
    $_SESSION['message'] = "The two passwords did not match";
}
}

mysqli_close($db);
?>

This code for some reason will not allow me to add the information to the database it will also not display my session messages

  • 2
    On top of the dupe, you also are simply ASSUMING your query will never fail. It doesn't, because you trashed your values by using the wrong escape function, trashed the query by not quoting the variables properly, and have absolutely NO error checking whatsoever, which would have told you about all of your sql syntax errors. – Marc B Oct 21 '16 at 21:06
  • The best thing to do here for debugging your code is to copy and paste your SQL command in phpmyadmin and check if there is any error before anything else (of course you have to change variables by values that you choose). –  Oct 21 '16 at 21:38
  • It shows an error at every single line – edward davies Oct 21 '16 at 22:09

0 Answers0