[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

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


Closed Thread
 
LinkBack Thread Tools
Old 08-11-2005, 12:12 PM   #1 (permalink)
Barru.
 
Barrucadu's Avatar
 
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,731
78.50 NP$ (Donate)

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']){
    
//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, 12:22 PM   #2 (permalink)
NamePros Member
 
Join Date: Jan 2005
Location: Texas USA
Posts: 71
203.00 NP$ (Donate)

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');

?>
__________________
I wonder...
Outer is offline  
Old 08-11-2005, 12:27 PM   #3 (permalink)
NPQ's PA, Slave, and On Call Coder

Technical Services


 
Eric's Avatar
 
Join Date: Mar 2005
Posts: 4,545
0.71 NP$ (Donate)

Eric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond repute

Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse
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){
   
header("Location: http://www.yourdomain.com/path/to/badlogin.php");
    }else {
        
//do nothing
        
exit;
    }
}
?>
Something like that?
__________________
Eric is offline  
Old 08-11-2005, 12:37 PM   #4 (permalink)
NamePros Member
 
Join Date: Jan 2005
Location: Texas USA
Posts: 71
203.00 NP$ (Donate)

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'])
{
   
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, 02:51 PM   #5 (permalink)
Eating Pie
 
iNod's Avatar
 
Join Date: Nov 2004
Location: Canada
Posts: 2,289
126.05 NP$ (Donate)

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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

Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 07:29 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85