Pass variables from Select to another form..help required
Posted: Tue Jan 24, 2012 4:11 pm
Hi,
See code below.... I want to values pass 'id', 'used', 'partno' to the next form opened so i can update a table...
See 1st form.... Followed by second form that does the Update....
any help greatly appreciated.
Thanks
See code below.... I want to values pass 'id', 'used', 'partno' to the next form opened so i can update a table...
See 1st form.... Followed by second form that does the Update....
any help greatly appreciated.
Thanks
Code: Select all
<form action="insert_story.php" method="post" onsubmit="return validate()">
<input type="hidden" name="page_number" value="1" />
<?PHP
$user_name = "dffgdf";
$password = "fdggf";
$database = "fdgfdg";
$server = "fdgdf";
$con = mysql_connect($server ,$user_name ,$password);
$db_found = mysql_select_db($database);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
$rchar=chr(rand(65,67));
$mysql = mysql_query("SELECT * FROM storydetails WHERE storyno = '1' AND partno = '$rchar' AND used <10");
while($row = mysql_fetch_array($mysql))
{
echo $row['text']. "<P/>" . "Story Number:" . $row['storyno']." Part: " . $row['partno']." Used: " . $row['used']. " ID : ". $row['id'];
echo "<br />";
}
echo "<p/>";
echo "<p/>";
// I want to pass these variables to next page
$_POST['id'];
$_POST['used'];
$_POST['partno'];
//
/*
loop to display answers
*/
$mysql1 = mysql_query("SELECT * FROM answers WHERE storyno = '1' AND partno = '$rchar' ");
while($row = mysql_fetch_array($mysql1))
{
echo "<input type='radio' value='" . $row['response'] . "' name='answer1' />" . $row['response'] . " + " . $row['storyno']. " + " . $row['partno']. " + " . $row['used'];
echo "<br />";
}
mysql_close($con);
?>
<br />
<input type="submit" />
</form>
Code: Select all
<?PHP
ob_start();
$user_name = "sdsd4";
$password = "sadsd3";
$database = "sdsadsad4";
$server = "sdsdsdsds";
$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);
if ($db_found) {
$mysql="INSERT INTO responses (response) VALUES ('$_POST[answer1]')";
$result = mysql_query($mysql);
// Want to used values from previous form here to update table...
$used = $_REQUEST["used"];
$id = $_REQUEST["id"];
$mysql1="UPDATE storydetails SET used='used'+1 WHERE id='id'";
$result = mysql_query($mysql1);
//
mysql_close($db_handle);
print "Records added to the database";
}
else {
print "Database NOT Found ";
mysql_close($db_handle);
}
// Go to next story ....
if (isset($_POST['page_number'])){
$page = $_POST['page_number'];
}
$nextpage = $page+1;
if ($nextpage == 4) {
header("location: thanks.htm");
} else {
header("location: story$nextpage.php");
}
ob_flush();
?>