Jump to content


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


POST Form not working - $_POST receiving variable name as the value

Recommended Posts

This is my first attempt to use the FORM POST method. My problem is that the receiving $_POST variable is getting the value equal to the POST'ed variable name (not the actual value of the variable).

form method="POST" page code:

<form action="orderupdate.php" enctype='multipart/form-data' method="POST">
<input type="hidden" name="order_id" value=$ordid>
  <input type="hidden" name="email_addr" value=$email>
  <input type="hidden" name="order_status" value=$statPublic>
<p align="center"><input name="Update Order" type="submit" value="Update Order" align="middle"></p>

orderupdate.php code:

<?$order_id = $_POST['order_id'];?>
<?$email_addr = $_POST['email_addr'];?>
<?$order_status = $_POST['order_status'];?>
<p><?printf ($order_id);?></p>
<p><?printf ($email_addr);?></p>
<p><?printf ($order_status);?></p>

The printf statements display the values: "$ordid $email $statPublic" rather than the actual values of the fields. If I add a printf statement to the "POSTing" form after the inputs, the value shows correctly (e.g. email_addr = dave@phpfreaks.com. If I change the input tag from type='hidden' to type='text' and enter a value, the value POSTs and displays correctly on the updateorder.php page. So I know the POST is working. It seems that the type='hidden' is my problem?

I did get the transfer of the variable values to work with the GET method, but I don't want the values to be part of the URL. I prefer to get the POST method to work.

???Thank you for your help.

Share this post

Link to post
Share on other sites
Change the input tags to this:

[code=php:0]<input type="hidden" name="order_id" value="<? echo($ordid); ?>">[/code]

I think that's the problem.

Share this post

Link to post
Share on other sites
The problem is that on the value, you are not putting quotes

value='".$something."' />

Share this post

Link to post
Share on other sites
;D Yipee! I am soooo grateful for your help. Jeremysr: you're solution was on the mark! I tried all 3 of onlyican's options; but they still just displayed what ever was in the quotes rather than the value of the variable.

I had fooled around with this problem for 6 hours reading and trying options before posting my question here. With your help, it was solved in a minute.

In reading my Programming PHP book to understand why the ?echo was required I now see that the echo() command puts the string from the PHP generated page into the HTML. I have a lot more learning to do.

Thank you for teaching me something!

Share this post

Link to post
Share on other sites
I though u were echoing the form

echo "<input type=...

Anything shown to the users machine needs to be in an echo (or print or simular functions)
if its not in an echo, its not read out

Share this post

Link to post
Share on other sites
Now I understand, thanks onlyican. In fact, the example I was using that did not echo the variable was echoing the form. Got it!

Share this post

Link to post
Share on other sites


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.