homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

redirecting from login depending on user id

Msg#: 4592866 posted 9:30 pm on Jul 13, 2013 (gmt 0)

I am new at PHP and am trying to figure out how to redirect a user based on their login. Specifically, I want certain links to appear for certain users, but not all users.

It seems to me that "GetSelfScript()" just sends the user to the login screen itself, but when submitted, the user does get directed to the Home Page. I can't figure out how it does it. Any help would be much appreciated.

<form id='login' action='<?php echo $fgmembersite->GetSelfScript(); ?>' method='post' accept-charset='UTF-8'>
<fieldset >

<input type='hidden' name='submitted' id='submitted' value='1'/>

<div class='short_explanation'>* required fields</div>

<div><span class='error'><?php echo $fgmembersite->GetErrorMessage(); ?></span></div>
<div class='container'>
<label for='username' >UserName*:</label><br/>
<input type='text' name='username' id='username' value='<?php echo $fgmembersite->SafeDisplay('username') ?>' maxlength="50" /><br/>
<span id='login_username_errorloc' class='error'></span>
<div class='container'>
<label for='password' >Password*:</label><br/>
<input type='password' name='password' id='password' maxlength="50" /><br/>
<span id='login_password_errorloc' class='error'></span>

<div class='container'>
<input type='submit' name='Submit' value='Submit' />
<div class='short_explanation'><a href='reset-pwd-req.php'>Forgot Password?</a></div>

From fg_membersite.php
function GetSelfScript()
return htmlentities($_SERVER['PHP_SELF']);



WebmasterWorld Senior Member 5+ Year Member

Msg#: 4592866 posted 10:50 pm on Jul 13, 2013 (gmt 0)

If I recall correctly, PHP_SELF contains the top level script.

For example:

require_once 'test.php';

echo $_SERVER['PHP_SELF'];

Script output:

But. That may not be the cause of confusion here.

I would hazard a guess that the login script, upon successful login issues a redirect header, like this:

header('Location: /index.php');


Msg#: 4592866 posted 8:43 pm on Jul 14, 2013 (gmt 0)

Thanks. I think I have that worked out now.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved