Cookies
Posted: Fri Mar 05, 2004 11:51 am
Hi,
Ive created a cookie on my login page which apparently works since i use Javascript:alert(document.cookie); and it picks up the cookie. But when i try to pass the cookie on any other page its not working. Any ideas?
heres my code
Edit: added php highlighting - Sami
Ive created a cookie on my login page which apparently works since i use Javascript:alert(document.cookie); and it picks up the cookie. But when i try to pass the cookie on any other page its not working. Any ideas?
heres my code
Code: Select all
<?php
require_once('../Connections/james.php');
function output_form ($error_message = '',$username ='')
{
print
'<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<div align="center"><p><img src="../Templates/background1_r1_c1.gif" width="800" height="151"></p>
<p>Welcome to Golf Competitions Online. </p>
<form method="POST" action"http://localhost/project/memberoptions/membersoptions.php">
<p></p>';
if ($error_message !='')
{
print '
<font color=Green>' .$error_message. '</font>';
}
print '
<p>Please Enter in your username and password Below:</p>
<br>
<p>User Name: <input text type="text" name="username"';
if ($username !='')
{
print 'value= "'.$username.'"';
}
print'
</p>
<p>Password: <input name="Password" text type="password">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit2" value="Reset">
</p>
</form>
<p align="left">Administrator enter here. </p>
<p align="left"><a href="http://localhost/project/Login Page/AdministratorLogin.php">enter details page</a><br>
</p>
<p> </p>
</div>
</body>
</html>';
}
mysql_select_db($database_james, $james);
if (isset($_POST['username']) and isset($_POST['Password']))
{
$sql = "SELECT password, memberID FROM membertable WHERE memberID ='$username' AND password = '$Password'";
$result = mysql_query($sql) or die("Error: Mysql error".mysql_error());
$num = mysql_num_rows($result);
$row = mysql_fetch_assoc($result);
if ($num != 0)
{
setcookie("user_name", $_POST['username']);
header ("location: http://localhost/project/memberoptions/ ... ptions.php");
}
else
{
output_form ('Incorrect please try again');
}
}
else
{
output_form();
}
?>