jfourman Posted August 18, 2006 Share Posted August 18, 2006 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. Quote Link to comment Share on other sites More sharing options...
Jeremysr Posted August 18, 2006 Share Posted August 18, 2006 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. Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 18, 2006 Share Posted August 18, 2006 The problem is that on the value, you are not putting quotesvalue="something";value='something';value='".$something."' /> Quote Link to comment Share on other sites More sharing options...
jfourman Posted August 18, 2006 Author Share Posted August 18, 2006 ;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! Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 18, 2006 Share Posted August 18, 2006 I though u were echoing the formecho "<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 Quote Link to comment Share on other sites More sharing options...
jfourman Posted August 18, 2006 Author Share Posted August 18, 2006 Now I understand, thanks onlyican. In fact, the example I was using that did not echo the variable was echoing the form. Got it! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.