Porkie Posted July 7, 2009 Share Posted July 7, 2009 <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); // Include the database connection file. include("connection.php"); // Check if a person has clicked on submit. if(isset($_POST['submit'])) { // Check if a person has filled every form. if(empty($_POST['username'])) echo "You Havent Filled In The Username Field."; elseif(empty($_POST['password'])) echo "You Havent Filled In The Password Field."; elseif(empty($_POST['password2'])) echo "You Havent Filled In The Confirm Password Field."; elseif(empty($_POST['email'])) echo "You Havent Filled In the Email Field."; exit; } // Create variables from each $_POST. $username = $_POST['username']; $password = $_POST['password']; $password2 = $_POST['password2']; $email = $_POST['email']; $account = $_POST['account']; // Now, compare passwords and check if they're the same. if($password != $password2) { // If the passwords are NOT the same. Again display an error message and redirect. echo "Sorry, Your Two Passwords Dont Match Up."; exit; } // Secure the password using an md5 hash. $password = md5($password); // Create a variable containing the SQL query. $query = "INSERT INTO `Members` (username, password, email, account) VALUES ('$username', '$password', '$email', '$account')"; // Perform the SQL query on the database. $result = mysql_query($query); // If the query failed, display an error. if(!$result) { // The dot seperates PHP code and plain text. echo "Your query failed. " . mysql_error(); } else { // Display a success message! echo "Welcome " . $username . " You are now registered"; } ?> after this ends it doesnt do anything except show a white screen i think its something wrong with the check the password field however iam confused? any help? cheers Quote Link to comment https://forums.phpfreaks.com/topic/165072-does-nothing/ Share on other sites More sharing options...
scott.stephan Posted July 7, 2009 Share Posted July 7, 2009 Best thing to do- Comment out some stuff, Save, Run. Repeat until you find the offender Quote Link to comment https://forums.phpfreaks.com/topic/165072-does-nothing/#findComment-870450 Share on other sites More sharing options...
p2grace Posted July 7, 2009 Share Posted July 7, 2009 You closed the if(isset($_POST['submit'])) { to early. The close should be at the end of the script (see below). Also, you need to clean your variables to protect from sql injection. <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); // Include the database connection file. include("connection.php"); // Check if a person has clicked on submit. if(isset($_POST['submit'])) { // Check if a person has filled every form. if(empty($_POST['username'])){ die("You Havent Filled In The Username Field."); }elseif(empty($_POST['password'])){ die("You Havent Filled In The Password Field."); }elseif(empty($_POST['password2'])){ die("You Havent Filled In The Confirm Password Field."); }elseif(empty($_POST['email'])){ die("You Havent Filled In the Email Field."); } // Create variables from each $_POST. $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $password2 = mysql_real_escape_string($_POST['password2']); $email = mysql_real_escape_string($_POST['email']); $account = mysql_real_escape_string($_POST['account']); // Now, compare passwords and check if they're the same. if($password != $password2) { // If the passwords are NOT the same. Again display an error message and redirect. echo "Sorry, Your Two Passwords Dont Match Up."; exit; } // Secure the password using an md5 hash. $password = md5($password); // Create a variable containing the SQL query. $query = "INSERT INTO `Members` (username, password, email, account) VALUES ('$username', '$password', '$email', '$account')"; // Perform the SQL query on the database. $result = mysql_query($query); // If the query failed, display an error. if(!$result) { // The dot seperates PHP code and plain text. echo "Your query failed. " . mysql_error(); } else { // Display a success message! echo "Welcome " . $username . " You are now registered"; } }else{ die("No post variables set"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/165072-does-nothing/#findComment-870468 Share on other sites More sharing options...
AwptiK Posted July 7, 2009 Share Posted July 7, 2009 your mysql_query($query); should be mysql_query($query,$con); (or whatever $connection you used) Quote Link to comment https://forums.phpfreaks.com/topic/165072-does-nothing/#findComment-870481 Share on other sites More sharing options...
p2grace Posted July 7, 2009 Share Posted July 7, 2009 your mysql_query($query); should be mysql_query($query,$con); (or whatever $connection you used) the "mysql_query($query,$con);" with the $con isn't always necessary. It depends on what's contained within your connection.php file. Quote Link to comment https://forums.phpfreaks.com/topic/165072-does-nothing/#findComment-870486 Share on other sites More sharing options...
AwptiK Posted July 7, 2009 Share Posted July 7, 2009 your mysql_query($query); should be mysql_query($query,$con); (or whatever $connection you used) the "mysql_query($query,$con);" with the $con isn't always necessary. It depends on what's contained within your connection.php file. Oh, thanks for that. Quote Link to comment https://forums.phpfreaks.com/topic/165072-does-nothing/#findComment-870488 Share on other sites More sharing options...
Maq Posted July 7, 2009 Share Posted July 7, 2009 your mysql_query($query); should be mysql_query($query,$con); (or whatever $connection you used) the "mysql_query($query,$con);" with the $con isn't always necessary. It depends on what's contained within your connection.php file. Oh, thanks for that. Read the manual for more information - mysql_query. Quote Link to comment https://forums.phpfreaks.com/topic/165072-does-nothing/#findComment-870505 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.