XGD Posted July 4, 2009 Share Posted July 4, 2009 Hello people,I've made this registration script that actually works, but i get weird problems when i try to submit it with empty fields or when i try to use 2 different passwords while registering.If i try to submit it without entering anything into the fields, i get the following error message:Didnt fill in FIRST NAMEDidnt fill in LAST NAMEDidnt enter EMAILDidnt enter passNotice: Undefined variable: fn in C:\Program Files\EasyPHP 3.0\www\register.php on line 76And if i try to submit it using 2 different passwords i get this:Passwords dont matchNotice: Undefined variable: p in C:\Program Files\EasyPHP 3.0\www\register.php on line 76so the script actually works, it registers normally if everything is OK, and it doesnt register if something is not valid, but i get these weird error messages of undefined variables that i believe i have defined.the script goes like this: <?php// SET UP THE DATA INPUT FIELDS if (isset($_POST['submit'])) { require_once('db_connect.php'); if (empty($_POST['first_name'])) { echo "Didnt fill in FIRST NAME<br />"; } else { $fn = trim($_POST['first_name']); } if (empty($_POST['last_name'])) { echo "Didnt fill in LAST NAME<br />"; } else { $ln = trim($_POST['last_name']); } if (empty($_POST['email'])) { echo "Didnt enter EMAIL<br />"; } else { $e = trim($_POST['email']); } if (!empty($_POST['pass1'])) { if ($_POST['pass1'] != $_POST['pass2']) { echo "Passwords dont match<br />"; } else { $p = trim($_POST['pass1']); } } else { echo "Didnt enter pass<br />"; } if (@$fn && $ln && $e && @$p) { // MAKE SURE EMAIL ADDRESS IS NOT ALREADY IN USE$q = "SELECT user_id FROM users WHERE email='$e'";$r = mysqli_query($dbc, $q) or trigger_error("Problem with query".mysqli_error($dbc));if (mysqli_num_rows($r) == 0) { $q = "INSERT INTO users (email, pass, first_name, last_name, reg_date) VALUES ('$e', SHA1('$p'), '$fn', '$ln', NOW() )"; $r = mysqli_query($dbc, $q) or trigger_error("error inserting".mysqli_error($dbc)); if (mysqli_affected_rows($dbc) == 1) { echo "you have been regiatered"; } else { echo "System error, you could not be registered"; } } else { echo "Email address already in use, choose another one"; } } } ?> Link to comment Share on other sites More sharing options...
jlhaslip Posted July 4, 2009 Share Posted July 4, 2009 where is line 76? Link to comment Share on other sites More sharing options...
pizzaguy Posted July 5, 2009 Share Posted July 5, 2009 try just putting this at the beginning of the script: $fn = NULL;$ln = NULL;$e = NULL;$p = NULL; Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.