Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

redirecting from login depending on user id



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


10:50 pm on Jul 13, 2013 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member

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


8:43 pm on Jul 14, 2013 (gmt 0)

Thanks. I think I have that worked out now.

Featured Threads

Hot Threads This Week

Hot Threads This Month