justinba1010 Posted October 22, 2011 Share Posted October 22, 2011 <?php //Register 1.0.1 include("function.php"); connect(); $num = 0; if(isset($_POST['submit'])) { if($_POST['username'] == '' || $_POST['password1'] == '' || $_POST['password2'] == '') { $num = 1; echo "Please supply all fields;"; exit(); } elseif(strlen($_POST['username']) > 25) { $num = 1; echo "Username must be under 25 characters long;"; exit(); } elseif(strlen($_POST['password1']) > 16) { if(strlen($_POST['password2']) >16) { $num = 1; echo "Password are over 16 characters long;"; exit(); } $num = 1; echo "Passwords are not equal"; exit(); } elseif($_POST['password1'] != $_POST['password2']) { $num = 1; echo "Passwords are not equal;"; exit(); } } else { if(isset($_POST['submit'])) { $username = $_POST['username']; safe($username); if($_POST['password1'] = $_POST['password2']) { $password = $_POST['password']; password($password); echo "INSERT INTO user (username, password) VALUES ('$username','$password')"; } else { echo "Passwords are not equal; Double Take";//Yes Double Take is a military term exit(); } } } ?> <HTML> <form action="register.php" method="post"> Username:<input type="text" name="username"> <br> Password:<input type="password" name="password1"> <br> Password Check:<input type="password" name="password2"> <br> <input type="submit" name="submit" value="Register!"> </HTML> Here is where I put the code: if(isset($_POST['submit'])) { $username = $_POST['username']; safe($username); if($_POST['password1'] = $_POST['password2']) { $password = $_POST['password']; password($password); echo "INSERT INTO user (username, password) VALUES ('$username','$password')"; } else { echo "Passwords are not equal; Double Take";//Yes Double Take is a military term exit(); } I used it like that to narrow it down. And I still do not understand the issue, are there any other issues? [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
trq Posted October 22, 2011 Share Posted October 22, 2011 You might want to actually give us some details of what your issue is. Quote Link to comment Share on other sites More sharing options...
trq Posted October 22, 2011 Share Posted October 22, 2011 Actually, it's pretty easy to see even without a decent description. You have this: if(isset($_POST['submit'])) And then within that statement is no code that actually executes any query. Quote Link to comment Share on other sites More sharing options...
trq Posted October 22, 2011 Share Posted October 22, 2011 You also have this: if($_POST['password1'] = $_POST['password2']) The = operator is for assigning, == is for comparing. Quote Link to comment Share on other sites More sharing options...
justinba1010 Posted October 22, 2011 Author Share Posted October 22, 2011 Notice: Undefined index: password in /opt/lampp/htdocs/game/register.php on line 46 INSERT INTO user (username, password) VALUES ('j','') When I changed it to <?php //Register 1.0.1 include("function.php"); connect(); $num = 0; if(isset($_POST['submit'])) { if($_POST['username'] == '' || $_POST['password1'] == '' || $_POST['password2'] == '') { $num = 1; echo "Please supply all fields;"; exit(); } elseif(strlen($_POST['username']) > 25) { $num = 1; echo "Username must be under 25 characters long;"; exit(); } elseif(strlen($_POST['password1']) > 16) { if(strlen($_POST['password2']) >16) { $num = 1; echo "Password are over 16 characters long;"; exit(); } $num = 1; echo "Passwords are not equal"; exit(); } elseif($_POST['password1'] !== $_POST['password2']) { $num = 1; echo "Passwords are not equal;"; exit(); } $username = $_POST['username']; safe($username); if($_POST['password1'] == $_POST['password2']) { $password = $_POST['password']; password($password); echo "INSERT INTO user (username, password) VALUES ('$username','$password')"; } } ?> <HTML> <form action="register.php" method="post"> Username:<input type="text" name="username"> <br> Password:<input type="password" name="password1"> <br> Password Check:<input type="password" name="password2"> <br> <input type="submit" name="submit" value="Register!"> </HTML> Quote Link to comment Share on other sites More sharing options...
trq Posted October 22, 2011 Share Posted October 22, 2011 Your not testing that $_POST['password'] exists before using it. See isset. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.