Good evening everyone,
I am running into an issue with my $SESSION and $POST. I will attempt to explain my set up as best I can.
First Page:
The user enters a 4 digit id number:
<form action="submit_review.php" method="post">
"<input name='comic_id' type='text' value='' size='5' maxlength='4'></td>";
Type in the four digit comic ID number.
<input type='submit' name='submit'>
</form>
Based on that four digit ID number the user is taken to page two where they are presented with a 2 field form. The title that corisonds to the id Number they entered, along with the comic_id is echoed so the user can verify the comic they were looking for is accurate.
Second Page:
<?php
session_start();
include ('../header.html');
$comic_id = $_POST['comic_id'];
include ('get_connected.php');
$sql = "SELECT * FROM comics WHERE comic_id = '" . mysql_real_escape_string($comic_id) . "'";
if ($result = mysql_query($sql)) {
if (mysql_num_rows($result)) {
$row = mysql_fetch_assoc($result);
}
}
if ($row ==!NULL) {
echo "You entered Comic ID #$comic_id. This number refers to " . $row['title'] . " #" . $row['issue_number'] . " ";
echo "<br>";
} else {
echo "<font color='red'><b>Sorry a comic matching ID number #$comic_id could not be located in the database. Please check the number and try again.</b></font>";
}
?>
<br><br><?php
if ($vbulletin->userinfo['usergroupid'] == '6') {
echo "<form action='preview_reviews.php' method='post'>";
}
?>
REVIEW:<br>
<textarea name="review" cols="80" rows="20"><?php echo stripslashes($_SESSION['review']); ?></textarea><br><br>
RATING:<br>
<input type="text" name="rating" value="<?php echo $_SESSION['rating'] ?>"></input><br>
<input type="hidden" name="comic_id" value="<?php echo $_SESSION['comic_id'] ?>"></input><br>
<input type="submit" name="submit" value="submit"/>
<?php
include ('../footing.html');
$_SESSION['title'] = $row['title'];
?>
Once they have filled out both forms on page two they hit submit and are taken to page three, a preview page. This allows the user to check for mistakes in spelling, etc. If the information is accurate they can hit submit again and the data is then processed into the database. If the data is in correct they can hit the "Go Back and Edit" link.
Page Three:
<?php
session_start();
include ('../header.html');
$_SESSION['review'] = $_POST['review'];
$_SESSION['rating'] = $_POST['rating'];
$_SESSION['comic_id'] = $_POST['comic_id'];
$comic_id = $_SESSION['comic_id'];
$review = $_SESSION['review'];
$rating = $_SESSION['rating'];
$title = $_SESSION['title'];
echo "$title<br><br>
$review<br><br>
$comic_id<br><br>
$rating";
?>
<form action="final_reviews.php" method="post">
<input type="submit" value="submit" name="submit">
</form>
<a href="submit_review.php">Go Back to Edit</a>
<?php include ('../footing.html'); ?>
This is the problem. If the user decides to go back instead of submitting the information, from page 3, the review field and rating field are stored in sessions and echoed back into the form fields.. which is good. But the comic_id number is lost along the way. Pretty sure it's a conflict of the $POST['comic_id'] and the $SESSION['comic_id']. I have spent two evening trying to rectify this without have to bother all of you good people, but I am stuck and must...
Can someone point me to the solution, so that if I chose to "Go Back and Edit" the comic_id is retained... without it, no one can edit their information.
Any advice or suggestions? Thank you in advance.
SC