Jump to content

Carrying hidden fields in a form.


topshelfbleu

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/215238-carrying-hidden-fields-in-a-form/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.