Unstoppable Domains

Redirecting pages

Spaceship Spaceship
Watch

Barrucadu

Established Member
Impact
64
OK, on my page it checks if the user is logged in, and there are 3 possible outcomes, if the user is not logged in it should redirect them to nologin.php if they have an invalid username/password they should be redirected to badlogin.php and if the username and password are correct it should leave them on that page. heres my current code but i cant find out how to redirect.:

PHP:
<?php
if(!$_GET['uid']){
	//redirect to nologin.php
}else if(!$_GET['pcode']){
	//redirect to nologin.php
}else{
	$users[] = file('users.log');
	foreach($users as $person){
		if(eregi($_POST['uid'].$_POST['pcode'],$person)){
			$usrfound = true;
		}
	}
	if(!userfound){
		//redirect to badlogin.php
	}else {
		//do nothing
		exit;
	}
}
?>
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Use this:

replace badlogin.php with what file you want the user sent to

PHP:
<?php

header('Location: badlogin.php');

?>
 
0
•••
PHP:
<?php
if(!$_GET['uid']){
   header("Location: http://www.yourdomain.com/path/to/nologin.php");
}else if(!$_GET['pcode']){
   header("Location: http://www.yourdomain.com/path/to/nologin.php");
}else{
    $users[] = file('users.log');
    foreach($users as $person){
        if(eregi($_POST['uid'].$_POST['pcode'],$person)){
            $usrfound = true;
        }
    }
    if(!userfound){
   header("Location: http://www.yourdomain.com/path/to/badlogin.php");
    }else {
        //do nothing
        exit;
    }
}
?>
Something like that? :)
 
0
•••
can shorten that I think :-/

Just a small thing just to keep you from repeating things

PHP:
<?php 
if(!$_GET['uid'] OR !$_GET['pcode'])
{ 
   header("Location: http://www.yourdomain.com/path/to/nologin.php"); 
}
else
{ 
    $users[] = file('users.log'); 
    foreach($users as $person)
    { 
        if(eregi($_POST['uid'].$_POST['pcode'],$person))
        { 
            $usrfound = true; 
        } 
    }
 
    if(!userfound)
    { 
        header("Location: http://www.yourdomain.com/path/to/badlogin.php"); 
    }
    else
    { 
        //do nothing 
        exit; 
    } 
} 
?>
 
0
•••
Another way of doing this insted of having 3 pages would be just to include error displying in the main one so
PHP:
if(isset($errorvariable)) {
switch ($errorvariable) {
case 1:
echo "<font color=red>Error: Bad user/password try again</font><br>";
break;
case 2:
?>
Form stuff
<? 
break;
}
}?>

And just change nologin.php and badlogin.php to index.php?errorvariableofchoosing=1
and index.php?errorvariableofchoosing=2

Best of luck!
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99
Appraise.net

We're social

Unstoppable Domains
Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back