NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Redirecting pages

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 08-11-2005, 01:12 PM THREAD STARTER               #1 (permalink)
Senior Member
 
Barrucadu's Avatar
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,689
Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold
 




Redirecting pages


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 Code:
<?php
if(!$_GET['uid']){
    
//redirect to nologin.php
}else if(!$_GET['pcode']){
????: NamePros.com http://www.namepros.com/programming/114773-redirecting-pages.html
    
//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;
    }
}
?>
Barrucadu is offline  
Old 08-11-2005, 01:22 PM   #2 (permalink)
NamePros Member
Join Date: Jan 2005
Location: Texas USA
Posts: 71
Outer is an unknown quantity at this point
 



Use this:

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

PHP Code:
<?php

header
('Location: badlogin.php');
????: NamePros.com http://www.namepros.com/showthread.php?t=114773

?>
__________________
I wonder...
Outer is offline  
Old 08-11-2005, 01:27 PM   #3 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
PHP Code:
<?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){
????: NamePros.com http://www.namepros.com/showthread.php?t=114773
   
header("Location: http://www.yourdomain.com/path/to/badlogin.php");
    }else {
        
//do nothing
        
exit;
    }
}
?>
Something like that?
Eric is offline  
Old 08-11-2005, 01:37 PM   #4 (permalink)
NamePros Member
Join Date: Jan 2005
Location: Texas USA
Posts: 71
Outer is an unknown quantity at this point
 



can shorten that I think :-/

Just a small thing just to keep you from repeating things

PHP Code:
<?php 
if(!$_GET['uid'] OR !$_GET['pcode'])
????: NamePros.com http://www.namepros.com/showthread.php?t=114773

   
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; 
    } 

?>
__________________
I wonder...
Outer is offline  
Old 08-11-2005, 03:51 PM   #5 (permalink)
Eating Pie
 
iNod's Avatar
Join Date: Nov 2004
Location: Canada
Posts: 2,272
iNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud of
 


Special Olympics AIDS/HIV Cystic Fibrosis Save The Children Baby Health Cystic Fibrosis
Another way of doing this insted of having 3 pages would be just to include error displying in the main one so
PHP Code:
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
????: NamePros.com http://www.namepros.com/showthread.php?t=114773
and index.php?errorvariableofchoosing=2

Best of luck!
__________________
I feel old.
iNod is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
From the horse's mouth: Optimization tips! IAmAllanShore Google Adsense 2 06-08-2005 10:39 PM
Good Article: An SEO Checklist Ferman Search Engines 2 05-28-2005 11:51 AM
appraise please Complete Hostings Domain Appraisals 2 01-19-2005 04:03 PM
Doorway Pages - advice needed Tjobbe Web Design Discussion 5 09-27-2004 11:17 AM
2 Huge Name Forsale Vegas Entertainment Domains For Sale - Make Offer 9 09-21-2004 03:37 PM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 05:39 PM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger