frijole Posted February 2, 2008 Share Posted February 2, 2008 i am trying to find a way to check if the password matches the saved one, or the second one in the register form, and if not echo that it is incorrect and show the form again for them to re-enter. Quote Link to comment https://forums.phpfreaks.com/topic/89095-solved-if-password-is-incorrect-how-do-i-redirect-back-to-loginregister/ Share on other sites More sharing options...
p2grace Posted February 2, 2008 Share Posted February 2, 2008 First of all, there are a hundred different ways to do this. A quick way would be to create a validation function in php and compare the two values. If they don't match redirect to the registration page while triggering an error through a get variable. Example: <?php // validation function, assuming you've already submitted the form grabbed the $_POST variables and send the variables to the validation function function validate($pass1,$pass2){ if($pass1 != $pass2){ header("Location: login.php?error=1"); } } ?> On the login page run a check for errors in the url. <?php if(isset($_GET['error'])){ if($error == 1){ echo "The password fields don't match!"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/89095-solved-if-password-is-incorrect-how-do-i-redirect-back-to-loginregister/#findComment-456345 Share on other sites More sharing options...
Kingy Posted February 2, 2008 Share Posted February 2, 2008 on my registration i have... <?php $password = $_POST['password']; $confirmpw = $_POST['confirmpw']; if($confirmpw != $password) { echo "Your passwords did not match. Please try again<BR />"; echo "Redirecting..."; echo "<meta http-equiv='refresh' content='3;url=index.php?action=register' />"; exit(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/89095-solved-if-password-is-incorrect-how-do-i-redirect-back-to-loginregister/#findComment-456346 Share on other sites More sharing options...
p2grace Posted February 2, 2008 Share Posted February 2, 2008 Ok? Did you try doing what I suggested? Quote Link to comment https://forums.phpfreaks.com/topic/89095-solved-if-password-is-incorrect-how-do-i-redirect-back-to-loginregister/#findComment-456353 Share on other sites More sharing options...
frijole Posted February 3, 2008 Author Share Posted February 3, 2008 thanks, ill give those a try. ill let you know how it goes. Quote Link to comment https://forums.phpfreaks.com/topic/89095-solved-if-password-is-incorrect-how-do-i-redirect-back-to-loginregister/#findComment-456432 Share on other sites More sharing options...
frijole Posted February 3, 2008 Author Share Posted February 3, 2008 If i want to use functions how do I attach them to the page? Should I simply make a functions.php and attatch it to all the registration page? include functions.php? Quote Link to comment https://forums.phpfreaks.com/topic/89095-solved-if-password-is-incorrect-how-do-i-redirect-back-to-loginregister/#findComment-456509 Share on other sites More sharing options...
p2grace Posted February 3, 2008 Share Posted February 3, 2008 That would work Quote Link to comment https://forums.phpfreaks.com/topic/89095-solved-if-password-is-incorrect-how-do-i-redirect-back-to-loginregister/#findComment-456510 Share on other sites More sharing options...
frijole Posted February 3, 2008 Author Share Posted February 3, 2008 thanks a lot, i got it. Quote Link to comment https://forums.phpfreaks.com/topic/89095-solved-if-password-is-incorrect-how-do-i-redirect-back-to-loginregister/#findComment-456515 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.