Dynadot โ€” .com Transfer

Redirecting pages

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
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.
AfternicAfternic
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 TransferDynadot โ€” .com Transfer
CatchedCatched
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back