Jump to content

[SOLVED] if password is incorrect, how do i redirect back to login/register?


Recommended Posts

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!";
}
}
?>

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();
  }
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.