Jump to content

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


jfourman

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>
</form>

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.
Link to comment
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!
Link to comment
Share on other sites

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.