topshelfbleu Posted October 5, 2010 Share Posted October 5, 2010 Hi I've got a form that users enter an identification pin in for their first question as well as clicking a radio button(Q1.php) . They click submit and the answers are put through a couple of multiplication function and then placed in a table (alongside the pin) via Q2.php. On the Q2 page I want to place the 2nd question that the user needs to answer. Rather than making them retype the pin I was hoping to process it as a hidden field - being picked up from their Q1.php entry. This 'hidden pin echo ' process will continue throughout Q2- Q10 pages. However - I can't seem to include any php in the page after the Q1 form has been processed. Have I got my php tags messed up? <?php $con = mysql_connect("localhost","ca","d"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("candango", $con); $q1 =$_POST['q1']; $pin =$_POST['pin']; $ans1 = $q1 * 3; $ans2 = $q1 * 5; $ans3 = $q1 * 2; $enter_sql= "INSERT INTO aapcm2 (pin,ans1, ans2, ans3) VALUES ('$pin','$ans1','$ans2','$ans3')"; $enter_query =mysql_query($enter_sql) or die (mysql_error()); ?> <body> <p>Thank you - You have successfully entered your answers.</p><form action="q2.php" method="post"> <p>What do you think the answer to this one is? <input type="radio" name="q2" id="q2" value="-3"> <label for="q2"></label> <input name="Hidden" type="hidden" id="Hidden" value="$pin" /></p> <p> <input type="submit" name="button" id="button" value="Submit"> </p> </form> <p></p> </body> Quote Link to comment https://forums.phpfreaks.com/topic/215238-carrying-hidden-fields-in-a-form/ Share on other sites More sharing options...
Pikachu2000 Posted October 5, 2010 Share Posted October 5, 2010 If I've interpreted what you mean correctly, value="$pin" should be value="<?php echo $pin; ?>" Quote Link to comment https://forums.phpfreaks.com/topic/215238-carrying-hidden-fields-in-a-form/#findComment-1119409 Share on other sites More sharing options...
topshelfbleu Posted October 5, 2010 Author Share Posted October 5, 2010 That is what I meant, and having tried it - it works. Very grateful. Nick Quote Link to comment https://forums.phpfreaks.com/topic/215238-carrying-hidden-fields-in-a-form/#findComment-1119417 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.