Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modifying a password script so it redirects on incorrect password 1

Status
Not open for further replies.

dpad

Technical User
Jan 21, 2009
4
CA
Hi there,

I have a password script for my website (the script is 'Page Password Protect 2.13'), but I can't figure out how to modify it so it redirects to an error page instead of just popping up 'incorrect password'.

I looked high and low on the internet for a good password script, and this was the only one I could find that was easy to setup and free.

This the is the part of the script that calls the incorrect password:

---------------------------------------------------------

// user provided password
if (isset($_POST['access_password'])) {

$login = isset($_POST['access_login']) ? $_POST['access_login'] : '';
$pass = $_POST['access_password'];
if (!USE_USERNAME && !in_array($pass, $LOGIN_INFORMATION)
|| (USE_USERNAME && ( !array_key_exists($login, $LOGIN_INFORMATION) || $LOGIN_INFORMATION[$login] != $pass ) )
) {
showLoginPasswordProtect("Invalid Password");
}
else {
// set cookie if password was validated
setcookie("verify", md5($login.'%'.$pass), $timeout, '/');

// Some programs (like Form1 Bilder) check $_POST array to see if parameters passed
// So need to clear password protector variables
unset($_POST['access_login']);
unset($_POST['access_password']);
unset($_POST['Submit']);
}

}

---------------------------------------------------------

Sorry for being such a newb, but PHP is totally foreign to me.

Any help would be greatly appreciated.
 
at first glance, change this line

Code:
showLoginPasswordProtect("Invalid Password");

to

Code:
header("Location: [URL unfurl="true"]http://example.com/path/to/redirect/page.php");[/URL]
 
Thanks jpadie.

That did the trick.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top