echo "<input type=\"hidden\" name=\"bname\" value=\"{$_POST['bFirstName']} + {$_POST['bLastName']}\">";
Passing php variables into html hidden fields.
if you have variables stored in <input> tags, they must be in a <form> and that form must be submitted in order for the variables to be sent.
hope this helps,
-Tim
feldon23,
I did what you said and now I'm getting this error:
Parse error: parse error, expecting `']'' in /home/whatnott/public_html/order.php on line 1878
and this is line1878:
echo "<input type=\"hidden\" name=\"bcity\" value=\"{$_POST['bCity']}\">";
Any ideas?
i would write the code like this
put this outside of php tags!
<input type="hidden" name="bcity" value="<?= $_POST['bCity'] ?>">
Is this correct?
value="<?= $_POST['bCity'] ?>"
do you need the '=' after the '?' or is that a mistake?
Hey, men... =)
use it:
$var = $_REQUEST["var"]; // or $_POST or $_GET
print "<input type='hidden' name='field' value='$var'>";
100% working.
SLAYeeK
If I have the two vars $city and $state
Then, would I use it like this:
PHP:
$city= $POST["city"]; // or $POST or $GET
$state= $POST["state"];
print "<input type='hidden' name='bcity' value='$city'>";
print "<input type='hidden' name='bstate' value='$state'>";
Thanks.
$var = $REQUEST["var"]; // or $POST or $_GET
print "<input type='hidden' name='field' value='$var'>";
Bad coding practices.
Feldon23
Why am I getting this error message?
Parse error: parse error, expecting `']'' in /home/whatnott/public_html/order.php on line 1878
This is what the code looks like. Do you see anything wrong with it?
echo "<input type=\"hidden\" name=\"bcity\" value=\"{$_POST['bCity']}\">";
Also, will it work the same if I get rid of the "" and \ like this?:
echo "<input type=hidden name=bcity value={$_POST['bCity']}>";
Thanks.
I can't understand why you are getting a parse error there. I tested it here and it works.
feldon,
okay I got it to not give me any parse errors. I don't know how, but I did. Problem is that I still don't think it is sending the values to the card processor. They told me that if it gets the values then it will automatically send them to our thank_you.html or sorry.html page depending on if the card goes through or not.
Reason I know the values aren't being sent properly is because it just takes you to a page for the card processor and stays there. They said if it does that, then the data is not being sent.
Can you take a look at my entire page for me? I have attached it in a zip file.
Thanks.
Originally posted by delstrange
SLAYeeK
If I have the two vars $city and $state
Then, would I use it like this:
PHP:
$city= $POST["city"]; // or $POST or $GET
$state= $POST["state"];
print "<input type='hidden' name='bcity' value='$city'>";
print "<input type='hidden' name='bstate' value='$state'>";
--------------------------------------------------------------------------------
Thanks.
Yes, you can =)
Originally posted by feldon23
Bad coding practices.
Why?