Jump to content

Carrying hidden fields in a form.


topshelfbleu
 Share

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
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • 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.