Reputation: 111
How does one send additional data to the next page with php if there is already a form doing it? For example
<form action='blah.php?variable1=$var' method='post'>
Example: <input type="text" name="example"><br>
</form>
Doesn't seem to direct to:
blah.php?variable1=thisVariable&example=thisExample
How would I go about this?
Upvotes: 0
Views: 28
Reputation: 1260
Assuming blah.php is in this same directory, suggest using ./
in front of the filename (not necessary, just suggested but the main problem is $var
won't get it's value printed in your code. You can print it out with the short tag method, like this..
<form action='./blah.php?variable1=<?=$var?>' method='post'>
or, a plain PHP echo like this...
<form action='./blah.php?variable1=<?php echo $var;?>' method='post'>
Upvotes: 0
Reputation: 42925
The easiest approach is to hand over the variable as hidden value:
<form action="blah.php" method="post">
<input type="hidden" name="variable1" value="<?=$var?>">
Example: <input type="text" name="example"><br>
</form>
For more complex situations you should use server side sessions to store such values, though.
Upvotes: 2