Dear all
Here is the Code for my Login.php page
<?php
// *** Start the session
session_start();
// *** Validate request to log in to this site.
$KT_LoginAction = $PHP_SELF;
if ($QUERY_STRING!="") $KT_LoginAction .= "?".$QUERY_STRING;
$KT_valUsername=$user;
if (isset($KT_valUsername)) {
$KT_fldUserAuthorization="Username";
$KT_redirectLoginSuccess="index.php";
$KT_redirectLoginFailed="LOGIN.php";
$KT_rsUser_Source="SELECT Username, Password ";
if ($KT_fldUserAuthorization != "") $KT_rsUser_Source .= "," .
$KT_fldUserAuthorization;
$KT_rsUser_Source .= " FROM login WHERE Username='" . $KT_valUsername . "'
AND Password='" . $password . "'";
$KT_rsUser=$Mysql_nedcorhk->Execute($KT_rsUser_Source) or
DIE($Mysql_nedcorhk->ErrorMsg());
if ($KT_rsUser->RecordCount()==1) {
// username and password match - this is a valid user
$KT_Username=$KT_valUsername;
session_register("KT_Username");
if ($KT_fldUserAuthorization != "") {
$KT_UserAuthorization=$KT_rsUser->Fields($KT_fldUserAuthorization);
} else {
$KT_UserAuthorization="";
}
session_register("KT_UserAuthorization");
if (isset($accessdenied) && false) {
$KT_redirectLoginSuccess = $accessdenied;
}
$KT_rsUser->Close();
session_register("KT_login_failed");
$KT_login_failed = false;
header ("Location: $KT_redirectLoginSuccess");
exit;
}
$KT_rsUser->Close();
session_register("KT_login_failed");
$KT_login_failed = true;
header ("Location: $KT_redirectLoginFailed");
exit;
setcookie("username",$user);
}
?>
<html>
<head>
<title>Login Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--
function MM_findObj(n, d) { file://v4.0
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers[i].document);
if(!x && document.getElementById) x=document.getElementById(n); return x;
}
function MM_validateForm() { file://v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2];
val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an
e-mail address.\n';
} else if (test!='R') {
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (val<min || max<val) errors+='- '+nm+' must contain a number
between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is
required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
file://-->
</script>
</head>
<body bgcolor="#E8E9E0" text="#000000" link="#0000FF" vlink="#0000FF"
alink="#FF0000">
<div align="center">
<p><b><font size="+3"><u>Nedcor Internal WebSite</u></font></b></p>
<p><b>Please Provide your Username and Password for the Internal
Web.</b></p>
<?
print ("Diagnostic Information<br>");
print ("Session Name : " . session_name() . "<br>\n");
print ("Session ID : " . session_id() . "<br>\n");
?>
<form action="<?php echo $KT_LoginAction?>" name="LOGIN" method="post"
onSubmit="MM_validateForm('user','','R','password','','R');return
document.MM_returnValue">
<table width="75%" border="0">
<tr>
<td width="49%">
<div align="right"><b>Username</b></div>
</td>
<td width="51%">
<input type="text" name="user">
</td>
</tr>
<tr>
<td width="49%">
<div align="right"><b>Password</b></div>
</td>
<td width="51%">
<input type="password" name="password">
</td>
</tr>
</table>
<p>
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit2" value="Reset">
</p>
</form>
<p> </p>
</div>
</body>
</html>
I had use the setcookie function in the script which is
<?setcookie("username",$user);?>, then in the Main.php page, i set another
script <?echo $HTTP_COOKIE_VARS["username"];?>.
Then the strange things happen, the Main.php won't show the name from
cookie! actually the $user you saw in setcookie is the input box where the
user input their username to login!!
Another way i had tried is , if i set the cookie like this
<?setcookie("username","jack");?>, then the Main.php will display it.
Could someone pls tell me why it happen like this???
Thx a lot!!
Jack
[EMAIL PROTECTED]
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]