Hey there,
This is a page I wrote that does that with sessions, sorry its a little
messy but it should help you with the general idea.
HTH,
Steve.
//Copy the below into a php file and change all the variables and sql
statement to reflect your own data.
<?
session_start();
if(isset($level)) session_destroy();
if (isset($submitbutton)):
$dbname = 'put yours here';
$hostname = 'put yours here';
$username = 'put yours here';
$password = 'put yours here';
$table = 'put yours here';
$id_link = mysql_connect($hostname, $username, $password);
if (!$id_link || !mysql_select_db($dbname)):
echo '<html><head><title>Error</title></head><body>';
echo '1:Connection to PHP has failed.';
echo '</body></html>';
exit();
endif;
$login_query = "SELECT l.LEVEL, l.Name, s.PLANT, s.Super_Index, p.PLANT as
itemtable FROM Master.login l";
$login_query.= " INNER JOIN Master.supervisors s ON l.Paswd_Index =";
$login_query.= " s.Login_Index INNER JOIN Master.plant_code p ON s.PLANT =
p.PLANT_CODE";
$login_query.= " WHERE l.USER='$user' AND l.PASSWORD='$pwd'";
$class_login = mysql_db_query($dbname,$login_query,$id_link) or die("Please
contact HR to be added to supervisors list.");
while ($login_arr = mysql_fetch_array($class_login)):
$level = $login_arr['LEVEL'];
$Name = $login_arr['Name'];
$Location = $login_arr['PLANT'];
$Super = $login_arr['Super_Index'];
$Items_Table = "Stores.items_".$login_arr['itemtable'];
endwhile;
if (isset($level)){
session_start();
session_register("level");
session_register("Name");
session_register("Super");
session_register("Location");
session_register("Items_Table");
$page = "main.php?option=vieworders";
header("Location: $page");
}
else
echo "<div align=center><h3><font color=red>Login <b>NOT</b> Successful,
Please try again.</font></h3></div>";
endif;
?>
<link rel="stylesheet" href="nice.css" type="text/css">
<html>
<body bgcolor="#F5F5F5" OnLoad="document.login.user.focus();">
<div> </div>
<p>
<p>
<div> </div>
<p>
<div align=center><h3>Enter user/pwd to enter Stores Administration
Panel.</h3></div>
<FORM METHOD="post" name=login ACTION=<?
echo"index.php?option=vieworders"?>>
<table border=0 width=75% align=center>
<tr>
<td align=center bgcolor=#FFFFFF><img src="../../imgs/LOGO3_18.bmp"
height=250 width=500></td>
</tr>
<tr>
<td bgcolor="#CCCCCC" align=center> <font
color="#000000"><b><i>User Name: </i></b></font><input type="text"
name="user" class="TextBox_b">
<font color="#000000"><b><i>Password: </i></b></font><input
type="password" name="pwd" class="TextBox_b"> <input
type="submit" name="submitbutton" value="Login" class="Button_F"></td>
</tr>
</table>
</body>
</html>
-----Original Message-----
From: YC Nyon [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 09, 2002 12:45 PM
To: [EMAIL PROTECTED]
Subject: [PHP] RE: A straightforward user login coding
I been searching for a user authentication codes all night but got no where
with the results.
Therefore, if someone can tell me where to find
1. a user authentication using Mysql
2. don't use cookies.
3. also a logout script.
my os is windows.
TIA
Nyon
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php