setcookie - jeg KAN ikke finde fejlen
Jeg har nu siddet den sidste time og proevet at finde fejlen i min kode. Problemet er, at min cookie ikke bliver sat overhovedet ... jeg HAR enabled cookies og proever med baade IE og NN.Jeg har to sider og jeg paster lige det meste af koden:
login.php3 (saetter cookie)
------------------
<script language="php">
if ( isset($author_name) && isset($author_password) )
{
$connection = mysql_connect("localhost", "root");
$db = "mnsp";
$result = mysql_db_query($db, "SELECT id FROM author WHERE name = '$author_name' AND password = '$author_password'", $connection);
$row = mysql_fetch_array($result);
$id = $row[0];
mysql_free_result($result);
if (!empty($id))
{
setcookie("author", "$id", time()+3600);
// found user - we need to redirect to another page.
Header("Location: index.php3");
exit;
}
}
</script>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="css/default.css">
</head>
<body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>
<table border="0" width="100%" cellspacing="0" cellpadding="0" valign="BOTTOM" align="center" bgcolor="#9C9689">
<tr>
<td width="50%"> </td>
<td width="580"><a href="index.php3"><img src="images/top.gif" border=0 width="580" height="44"></a></td>
<td width="50%"> </td>
</tr>
<tr>
<td width="50%"> </td>
<td width="580" bgcolor="#CEC6B3" align="right" class="navigation"><img border="0" src="images/spacer.gif" width="10" height="10"></td>
<td width="50%"> </td>
</tr>
</table>
<table border="0" width="580" cellpadding="0" bgcolor="#E0DACA" cellspacing="0" align="center">
<tr>
<td width="10"><img border="0" src="images/spacer.gif" width="10" height="10"></td>
<td width="560"><img border="0" src="images/spacer.gif" width="10" height="10"></td>
<td width="10"><img border="0" src="images/spacer.gif" width="10" height="10"></td>
</tr>
<tr>
<td width="10">
<img border="0" src="images/spacer.gif" width="10" height="10"></td>
<td width="560">
<p align="justify"></p>
<p align="justify">
</p>
<form method="POST" action="login.php3">
<table border="0" width="100%" cellspacing="0" cellpadding="4">
<tr>
<td width="50%" align="right">navn</td>
<td width="50%"><input type="text" name="author_name" size="20"></td>
</tr>
<tr>
<td width="50%" align="right">password</td>
<td width="50%"><input type="password" name="author_password" size="20"></td>
</tr>
<tr>
<td width="50%" align="right"></td>
<td width="50%"><input type="submit" value="login" name="B1"></td>
</tr>
</table>
</form>
<p align="justify">
</p>
<p align="justify">
</p>
<p align="justify">
</p>
<p align="justify" class="copyright"><a
href="mailto:webmaster@mnsp.f2s.com">webmaster@mnsp.f2.com</a> - <img src="images/spacer.gif" width="1" height="4">copyright
©2000 mnsp.f2s.com</p>
</td>
<td width="10"><img border="0" src="images/spacer.gif" width="10" height="10"></td>
</tr>
<tr>
<td width="10" bgcolor="#C0BAAD"><img border="0" src="images/curve_bottomleft.gif" width="10" height="10"></td>
<td width="560"><img border="0" src="images/spacer.gif" width="10" height="10"></td>
<td width="10" bgcolor="#C0BAAD"><img border="0" src="images/curve_bottomright.gif" width="10" height="10"></td>
</tr>
</table>
</body>
</html>
index.php3 (laeser cookie)
-------------------------------
<script language="php">
if (!isset($author))
{
Header("Location: login.php3");
exit;
}
</script>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="css/default.css">
</head>
<body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>
<script language="php">
printf("<h1> : ".$author." : </h1>");
</script>
---
Er der nogen, der kan gennemskue problemet i ovenstaaende?