John Account
asked on
Again, problems with a remember me option
I have this code, which I initially had problems with, then posted a question on experts and found a working solution, only that solution is no longer working for some strange reason. I tried several different things, but those darn username and password cookies never get set... can anyone look my code over and see if there is anything wrong with that?
Julia
====================
<script language="JavaScript" src="inc/js/bot.js"></scri pt>
<?
if (isset($_GET[remember])) {
$username = $_GET[user_name];
setcookie("username",$user name,time( )+3600*24* 30, '/');
$password = $_GET[password];
setcookie("password",$pass word,time( )+3600*24* 30, '/');
}
elseif (isset($_COOKIE[username]) ) {
$username = $_COOKIE[username];
$password = $_COOKIE[password];
}
?>
<script language="JavaScript">
var fileType = "php";
function openChat() {
var user_name = document.ChatForm.user_nam e.value;
var password = document.ChatForm.password .value;
window.open('messengerxm.p hp?user_na me='+user_ name+'&pas sword='+pa ssword,'', 'toolbars= 0,menubar= 0,scrollba rs=0,statu s=0;');win dow.focus( );
}
</script>
<style>
BODY,P,TD {font-family:Verdana, Arial, Helvetica, sans-serif;font-size:10px; }
</style>
</head>
<body leftmargin="50" topmargin="0" scroll=no background="http://www.lovelinepersonals.com/images/messbg.gif" scroll="auto">
<form action= "#thanks" name="ChatForm" >
<table border="0" >
<tr>
<td><a name="login">username  ; &nb sp; <input type="text" name="user_name" value="<? if (isset ($username)) { echo $username; } ?>" size="10"></td>
</tr>
<tr>
<td>password &n bsp; <input type="password" name="password" value="<? if (isset ($password)) {echo $password; } ?>" size="10"></td>
<? if (isset($username)) {
echo '';
} else { ?>
</tr><tr><td colspan="2" align="left"><input type="checkbox" name="remember">
<font size="2"><font size=1>Remember me</font></td></tr>
<? } ?>
</table>
Julia
====================
<script language="JavaScript" src="inc/js/bot.js"></scri
<?
if (isset($_GET[remember])) {
$username = $_GET[user_name];
setcookie("username",$user
$password = $_GET[password];
setcookie("password",$pass
}
elseif (isset($_COOKIE[username])
$username = $_COOKIE[username];
$password = $_COOKIE[password];
}
?>
<script language="JavaScript">
var fileType = "php";
function openChat() {
var user_name = document.ChatForm.user_nam
var password = document.ChatForm.password
window.open('messengerxm.p
}
</script>
<style>
BODY,P,TD {font-family:Verdana, Arial, Helvetica, sans-serif;font-size:10px;
</style>
</head>
<body leftmargin="50" topmargin="0" scroll=no background="http://www.lovelinepersonals.com/images/messbg.gif" scroll="auto">
<form action= "#thanks" name="ChatForm" >
<table border="0" >
<tr>
<td><a name="login">username 
</tr>
<tr>
<td>password &n
<? if (isset($username)) {
echo '';
} else { ?>
</tr><tr><td colspan="2" align="left"><input type="checkbox" name="remember">
<font size="2"><font size=1>Remember me</font></td></tr>
<? } ?>
</table>
ASKER
nope, I already tried that... not working
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
p.s., please award points to both your questions :) thanks!
Try putting single quotes around all your array indexes.
ie. $_POST[username] becomes $_POST['username']
The same goes for your $_COOKIE array indexes as well.