ngreenwood6 Posted August 4, 2008 Share Posted August 4, 2008 I am trying to redirect to another page if the $new_pass is not set. It is not working, but it checks to make sure that $new_pass and $confirm_pass match. Any help is appreciated. <?php session_start(); $new_pass = Trim(stripslashes(md5($_POST['new_pass']))); $confirm_pass = Trim(stripslashes(md5($_POST['confirm_pass']))); //define the database variables $host = "localhost"; $db_name = "login"; $db_table = "members"; $db_username = "root"; $db_password = ""; //function to insert the data into the database $update_db = "UPDATE members SET password = '$new_pass' WHERE email = '$reset_email'"; //variable to connect to database $mysqli_connect = mysqli_connect($host,$db_username,$db_password,$db_name) or die ("Could not connect to database"); if (!$new_pass) { include("valid_password.php"); } elseif(!$confirm_pass) { include("valid_password.php"); } elseif($new_pass != $confirm_pass) { include("dont_match.php"); } else { //variable to send data to the database mysqli_query($mysqli_connect,$update_db) or die ("Error: ".mysqli_error($mysqli_connect)); include("reset_finished.php"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/118172-help-with-error/ Share on other sites More sharing options...
DarkWater Posted August 4, 2008 Share Posted August 4, 2008 Okay, and what's it doing wrong? >_> Quote Link to comment https://forums.phpfreaks.com/topic/118172-help-with-error/#findComment-608051 Share on other sites More sharing options...
.josh Posted August 4, 2008 Share Posted August 4, 2008 mysqli_query($update_db, $mysqli_connect) you had the arguments reversed Quote Link to comment https://forums.phpfreaks.com/topic/118172-help-with-error/#findComment-608052 Share on other sites More sharing options...
revraz Posted August 4, 2008 Share Posted August 4, 2008 Your logic has many flaws in it. Look at the order you are doing things and ask yourself it makes sense. Why would you try to update a DB if there may not even be data in the variables? Quote Link to comment https://forums.phpfreaks.com/topic/118172-help-with-error/#findComment-608056 Share on other sites More sharing options...
ngreenwood6 Posted August 4, 2008 Author Share Posted August 4, 2008 It is not checking to see if the $new_pass is set. It just goes past it if I dont put anything in the $new_pass field. Quote Link to comment https://forums.phpfreaks.com/topic/118172-help-with-error/#findComment-608057 Share on other sites More sharing options...
revraz Posted August 4, 2008 Share Posted August 4, 2008 try using isset Quote Link to comment https://forums.phpfreaks.com/topic/118172-help-with-error/#findComment-608059 Share on other sites More sharing options...
ngreenwood6 Posted August 4, 2008 Author Share Posted August 4, 2008 i tried using isset but it did not work either. is there anything that looks like it may be improperly set? Quote Link to comment https://forums.phpfreaks.com/topic/118172-help-with-error/#findComment-608064 Share on other sites More sharing options...
revraz Posted August 4, 2008 Share Posted August 4, 2008 Don't know, we can't see your form. Quote Link to comment https://forums.phpfreaks.com/topic/118172-help-with-error/#findComment-608067 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.