Jump to content

Recommended Posts

A user fills out a couple of text fields and the form is submitted and I use $_POST to get those answer's. What I want to do is to send a variable (i.e. $dummy) from that form page to the page which will process the form (both are php). How would I go about this? I tried using a hidden text field although this did not work.

A hidden field should work fine, but it would help to see your code so we can see how you have defined your variable, but generally this is how you would do it. I dont know what your variable does so i'll assume it holds a static value like an email address.

 

<?
$email="[email protected]";
?>
<form action="nextpage.php" method="post" name="form1">
Your Name: <input type="text" name="name" value="" /><br />
Your Email: <input type="text" name="useremail" value="" /><br />
Comments: <textarea name="comments"></textarea>
<input type="hidden" name="email" value="<? echo $email ?"><br />
<input type="submit" name="send" value="Send">
<input type="reset" name="reset" value="Reset">
</form?

Then to capture it on the nextpage.php

<?
$name=$_POST['name'];
$useremail=$_POST['useremail'];
$comments=$_POST['comments'];

// This is your hidden field
$email=$_POST['email'];

?>

 

That should do you!

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

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