hello,
i have written a script where people can leave hall of fame members a message.
when i click the " leave a message " button, a viariable called $person_ID is set to the relevant hall of fame member and the page comment.php is opened.
when i enter a comment and press submit. the comment gets stored in the database under the right user. however. it is supposed to go back to the previous page wich displays the hall of fame member details. the problem is that the variable $perons_ID seems to loose its value after the submit.
as a result of this i get errors on the hall of fame member detail page because no $person_ID is selected.
here is the comment.php
<?
include "global.php";
setcookie("userID", "$person_ID");
$host = "localhost";
$user = "*********";
$pass = "*********";
$db = "********_hallfame";
$conn = mysql_connect($host, $user, $pass)
OR DIE (mysql_error());
@mysql_select_db ($db) OR DIE (mysql_error());
if ($_SERVER['REQUEST_METHOD'] == "POST")
{
$blogquery = "INSERT INTO visitors_comments"
. "(person_ID, visitor_comment, comment_date) ";
$blogquery.= "VALUES (";
$blogquery.= "'{$_COOKIE[userID]}', '{$blog_entry}', NOW())";
#execute SQL statement
$result = mysql_query($blogquery);
# check for error
if (mysql_error()) { print "Database ERROR: " . mysql_error(); }
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'legend.php?person_ID=$person_ID';
header("Location: http://$host$uri/$extra");
exit;
}
echo "cookie = $_COOKIE[userID]";
ob_end_flush();
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form name="fa" action="comment.php" method="POST">
<table>
<tr><td valign=top><b><font color="#999999">leave this legend a message </b> </td><td> <textarea name="blog_entry" rows=4 cols=30></textarea></td></tr>
<tr><th colspan=2><p><input type="submit" value="post it!!"></p></th></tr>
</table>
</form>
</body>
</html>
the hall of fame member detail page is called legend.php and looks like this
<?
ob_start();
include "include/session.php";
//setcookie("userID", "$person_ID");
$host = "localhost";
$user = "*******";
$pass = "********";
$db = "**********_hallfame";
$conn = mysql_connect($host, $user, $pass)
OR DIE (mysql_error());
@mysql_select_db ($db) OR DIE (mysql_error());
$iidquery = "select image_id from mugshot where mugshot.person_ID = ".$person_ID;
$iidresult = mysql_query ($iidquery);
$query = "select * from mugshot where mugshot.person_ID = ".$person_ID;
if ($_SERVER['REQUEST_METHOD'] == "POST")
{
mysql_query ("UPDATE shaggability SET total_score = total_score+ ".$rating." where person_ID = ".$_COOKIE[userID]);
}
$result = mysql_query ($query);
if (mysql_num_rows ($result)>0) {
$row = @mysql_fetch_array ($result);
$image_type = $row["image_type"];
$image = $row["image"];
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
/* The following rule...specifically its height...is the only bit needed to make the table scroll */
.scrollwrap { height:14em; border:1px dotted #fff; border-style:dotted none; background-color:#000 }
div.scrollhead { margin-top:0em }
div.scrollfoot { margin-bottom:0em }
</style>
<style type="text/css">
table.columnar { margin:0em 0 }
table.columnar td { padding:0em; vertical-align:top; border-bottom:1px solid #eee; padding-right:1em }
table.columnar thead *,
table.columnar tfoot * { text-align:center; vertical-align:bottom, padding-right:1em; font-family:Verdana,sans-serif; font-size:85%; font-weight:bold }
table.columnar thead * { vertical-align:top }
table.columnar tfoot th,
table.columnar tfoot td { vertical-align:top; border:none }
</style>
<script type="text/javascript" src="http://phrogz.net/common/AttachEvent.js"></script>
<script type="text/javascript" src="http://phrogz.net/common/AddClassKillClass.js"></script>
<script type="text/javascript" src="scrolltable.js"></script>
<link rel="stylesheet" href="styles.css" type="text/css">
<style type="text/css">
<!--
.style1 {color: #66FF00}
-->
</style>
<style>
body {
background-color: #000000;
}
</style>
</head>
<body>
<table width="1024" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="19" height="76"> </td>
<td colspan="2" valign="top"><img src="../Images/smashed-logo-new.gif" width="248" height="76"></td>
<td width="162"> </td>
<td width="97"> </td>
<td width="254"> </td>
<td width="45"> </td>
<td width="197"> </td>
</tr>
<tr>
<td height="63"> </td>
<td colspan="2" valign="top"><h1 align="center" class="style1">Hall of Fame </h1></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="21"> </td>
<td width="169"> </td>
<td width="81"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="140"> </td>
<td rowspan="2" valign="top"><?php $iidquery = "select image_id from mugshot where mugshot.person_ID = ".person_ID;
$iidresult = mysql_query ($iidquery);
$query = "select * from mugshot where mugshot.person_ID = ".$person_ID;
$result = mysql_query ($query);
if (mysql_num_rows ($result)>0) {
$row = @mysql_fetch_array ($result);
$image_type = $row["image_type"];
$image = $row["image"];
}
print " <img border=\"0\" height=\"213\" width=\"170\"img src=\"image1.php?iid=$iid\">"?> </td>
<td valign="top"><font color="#0000FF">
<!--DWLayoutEmptyCell-->
Name:<br />
A.K.A<br />
Status:<br />
Country:</td>
<td valign="top"><?php // Do this process if user has browse the
// file and click the submit button
some stuff left out because post got over 10.000 characters......
<?
echo "<a href=comment.php?person_ID=$person_ID>leave this legend a message</a>";
?>
</body>
</html>
can anyone tell me why $person_ID looses its value and what to to about it?