nashyboy Posted March 2, 2007 Share Posted March 2, 2007 Hi guys, im using this script i've come across which is working nicely. However there is something that im trying to add. The login script is this... <html> <head> <title>Login</title> </head> <body> <div align="center"> <br> <strong><font color="#999999" size="7" face="Courier New, Courier, mono">A D M I N I S T R A T I O N</font></strong><br> <br> <br> <font color="#FF8000" face="Arial, Helvetica, sans-serif"><strong>This Is A Restricted Area. Please Login ...</strong></font> <br> <br> <form method="post" action="<? echo ($PHP_SELF); ?>"> <table border=0 cols=2 width=200 cellpadding=3 cellspacing=3> <tr> <td width=100><font color="#000080" size="2" face="Arial, Helvetica, sans-serif"> User ID: </font></td> <td width=100> <input type="text" name="uid" size="8"> </td> </tr> <tr> <td width=100><font color="#000080" size="2" face="Arial, Helvetica, sans-serif"> Password: </font></td> <td width=100> <input type="password" name="pwd" SIZE="8"> </td> </tr> </table> <br> <input type="submit" name="submitlogin" value="Login"> </form> </div> </body> </htML> which obviously redirects to the index page which has the following include file <?php include ("access_control.php"); ?> This include file contains... <? include ("config.php"); include ("errors.php"); include ("common.php"); include ("connect.php"); while (list($var, $val) = each ($_REQUEST)) { IF ($var == "cookieid" AND !isset($_COOKIE[cookieid])) { echo ("You can not pass login parameters via GET operations."); exit(); } } reset($_REQUEST); IF (isset($_REQUEST[uid]) AND !isset($_COOKIE[cookieid])) { $grabuser = "SELECT recID FROM user WHERE username = '$_REQUEST[uid]' AND password = '$_REQUEST[pwd]'"; $result = @mysql_query($grabuser); sql_query($result, "$errors[03]"); IF (@mysql_num_rows($result) == 0) { error ("$errors[04]"); include ("login_form.php"); exit(); } ELSE { $userid = @mysql_result($result,0,"recID"); $processing_login = true; $cookie_setter = @setcookie ("cookieid", $userid, time()+$maxlifetime); IF (!$cookie_setter) { error ("$errors[05]"); } ELSE { ?> <META HTTP-EQUIV=Refresh CONTENT="2; URL=index.php"> <font color="#000080" size="2" face="Arial, Helvetica, sans-serif">Please hold one second while we process your login...<br> If this page does not refresh in 3 seconds, <A HREF="index.php">click here</a>. <? exit(); } } } ELSE IF (!isset($_REQUEST[uid]) AND !isset($_COOKIE[cookieid])) { include ("login_form.php"); exit(); } IF ($_REQUEST[action] == "logout") { $cookie_setter = @setcookie ("cookieid", $userid, time()-$maxlifetime); IF (!$cookie_setter) { error ("$errors[05]"); } ELSE { ?> </font> <META HTTP-EQUIV=Refresh CONTENT="2; URL=index.php"> <font color="#000080" size="2" face="Arial, Helvetica, sans-serif"> Please hold one second while we log you out...<br> If this page does not refresh in 3 seconds, <A HREF="index.php">click here</a>. </font><BR> <BR><BR><BR> <? exit(); } } ?> Basically what im trying to do is parse the username value though to the index page, so i can say hello user: $username etc etc. However i can't work out what code to put in on the index page. Can someone help, it would be appreciated. Thanks. Link to comment https://forums.phpfreaks.com/topic/40856-authentication-help/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.