Hi,
I have put a comments box on the bottom of a page and want the page to re-load after the comment is submitted so that the user can see their comment on the page. The page name is photo.php?date=20120101 where the date string can be different depending on which photo the user is viewing. Users do not need to log in to leave feedback. I've pasted my code below (that comes after the form being defined etc.) - any tips on why it's not working would be much appreciated!
The problem is that after submitting a post, the user is returned to photo.php with the value of today's date (which is the behaviour of index.html) rather than the specified date, i.e. going to photo.php?date=20120101 because that's today rather than photo.php?date=20111214 if that's what I've tried to specify in the code.
if($POST) {
if((!$POST["post_text"]) || (!$POST["post_owner"]) || (!$POST["post_id"])) {
echo "<p>PLEASE ENSURE YOU ADD BOTH YOUR NAME AND A COMMENT BEFORE SUBMITTING</p>";
}$add_post_sql="[removed for clarity]!;
$add_post_res=mysql_query("{$add_post_sql}",$cyoyo) or die("Could not complete post");
mysql_close($cyoyo);
$newurl="photo.php?date=".$imgdate;
header("Location: ".$newurl);
It's not that the script doesn't work at all:
- Comments are posted successfully
- If I echo $imgdate, the correct date is returned
- If I echo $newurl, the correct url is returned
- If I manually navigate in the browser to photo.php with a different value for date, the site behaves as I would expect (i.e. you navigate to that photo, not today's)
I'm not sure if the above is clear - please let me know if not!
Thanks,
Pav