hbradshaw
05-02-2005, 12:45 PM
Hello:
I have a login script in which I want to set a cookie. A cookie should be set only if a user checks the box, Remember Me.
When I run my script, I'm receiving a blank page. I tried placing the code in different places within the script and the result is always the same.
Can someone take a look at my script and help me set my cookie properly?
Thank you very much.
Here's the script:
<?php
session_start();
header("Cache-control: private");
include "conn.inc.php";
switch($_REQUEST['req'])
{
case "validate":
$validate = mysql_query("SELECT * FROM member WHERE
username = '{$_POST['username']}' AND password = md5('{$_POST['password']}')") or
die (mysql_error());
if (mysql_num_rows($validate) == 1)
{
while($row = mysql_fetch_assoc($validate))
{
$_SESSION["status"] = "Logged";
$_SESSION['memberid'] = $row['memberid'];
$_SESSION['first_name'] = $row['first_name'];
$_SESSION['last_name'] = $row['last_name'];
$_SESSION['email'] = $row['email'];
$_SESSION['phone1'] = $row['phone1'];
$_SESSION['phone2'] = $row['phone2'];
$_SESSION['username'] = $row['username'];
$_SESSION['password'] = $row['password'];
if ($_POST[remember] == "Yes")
{
setcookie("username", $_SESSION['username'], time()+(60*60*24), ".http://www.bridgemilltennis.com";
setcookie("password", $_SESSION['password'], time()+(60*60*24), ".http://www.bridgemilltennis.com";
}
$login_time = mysql_query("UPDATE member SET last_login=now() where memberid='{$row['memberid']}'");
}
header("Location: http://www.bridgemilltennis.com/mem...r-area-main.php");
}
else
{
$_SESSION["status"] = "Not logged";
$_SESSION['username'] = Guest;
header("Location: http://www.bridgemilltennis.com/mem.../login_form.php");
exit;
}
break;
}
?>
I have a login script in which I want to set a cookie. A cookie should be set only if a user checks the box, Remember Me.
When I run my script, I'm receiving a blank page. I tried placing the code in different places within the script and the result is always the same.
Can someone take a look at my script and help me set my cookie properly?
Thank you very much.
Here's the script:
<?php
session_start();
header("Cache-control: private");
include "conn.inc.php";
switch($_REQUEST['req'])
{
case "validate":
$validate = mysql_query("SELECT * FROM member WHERE
username = '{$_POST['username']}' AND password = md5('{$_POST['password']}')") or
die (mysql_error());
if (mysql_num_rows($validate) == 1)
{
while($row = mysql_fetch_assoc($validate))
{
$_SESSION["status"] = "Logged";
$_SESSION['memberid'] = $row['memberid'];
$_SESSION['first_name'] = $row['first_name'];
$_SESSION['last_name'] = $row['last_name'];
$_SESSION['email'] = $row['email'];
$_SESSION['phone1'] = $row['phone1'];
$_SESSION['phone2'] = $row['phone2'];
$_SESSION['username'] = $row['username'];
$_SESSION['password'] = $row['password'];
if ($_POST[remember] == "Yes")
{
setcookie("username", $_SESSION['username'], time()+(60*60*24), ".http://www.bridgemilltennis.com";
setcookie("password", $_SESSION['password'], time()+(60*60*24), ".http://www.bridgemilltennis.com";
}
$login_time = mysql_query("UPDATE member SET last_login=now() where memberid='{$row['memberid']}'");
}
header("Location: http://www.bridgemilltennis.com/mem...r-area-main.php");
}
else
{
$_SESSION["status"] = "Not logged";
$_SESSION['username'] = Guest;
header("Location: http://www.bridgemilltennis.com/mem.../login_form.php");
exit;
}
break;
}
?>