Forum Moderators: coopster
I'm working on a form of rating system for user generated stories, somewhat like Digg and Slashdot. The way users get to stories is by putting in the ID of the story in a box and the script pulls it up, and the post data is what the script uses to find the story. My problem is when one goes to rate a story, that post data is gone, and I can't think of a way to keep that in memory.
In case I didn't make that clear, here are the variables that are crucial.
$linkid = $_POST['linkid'];
$result = mysql_query("SELECT * FROM links WHERE link_id = linkid");
Essentially, everything refers to itself through that post data. Is there any way to keep that in memory, so things can work? If I'm doing this completely wrong, I'm willing to rewrite it.
You can also move it into the url and subsequently retrieve it with GET
<div>story</div>
<div>Click <a href="ratestory.php?id=<?php echo $linkid;?>">here</a> to rate the story</div>
If that's all you have to save, you don't really need to put it into a database, just use sessions:
$_SESSION['id'] = $linkid;
Then on the page that needs it:
$linkid = $_SESSION['id'];
You may need to use session_start() [us.php.net] if session.auto_start isn't set in your php configuration.