Hope everyone is having a great day. I am relatively new to PHP and mySQL and have developed a website that has an order form and a order confirmation page. The problem that I'm having is with the spaces (" ") in the order form text fields. Basically, the order form form is sending the form contents with a "GET"....the variables go through an error checking page....if no errors then it takes the $QUERY_STRING and redirects the process to the order confirm page. The $QUERY_STRING fields then are used to populate fields on the order confirm page, but additionally, I have an "Edit Information" link, whereby the customer can go back to the order form and update information....this link is the problem:
- When spaces in order form fields, submit page, and the "Edit Information" link gives an error:
"Warning: printf(): too few arguments in /home/virtual/site231/fst/var/www/html/index_files/order_confirm.php on line 1700".
However, all the values from the $QUERY_STRING display correctly in the order confirm detail section. When no spaces are in the order form fields, this error does not occur and there is no problem. I am also able to click the "Edit Information" link and go back to the order form screen where all $QUERY_STRING information is correctly represented.
- When I attempt to add urlencoding on the error checking page (in the URL redirect after no errors are found) and urldecoding to the order confirm page, everything works fine EXCEPT if I try to click the "Edit Information" link...all values are lost in the previous order form page...and db errors occur.
Notes: The variable "$querystring" is something that I set = "$QUERY_STRING" at the top of the error checking page...the other variables are fields that are populated on the error checking page and were not in the original $QUERY_STRING (for example, if bill to info is same as ship to...then copy bill-to information into ship to fields)
//Redirect Code on error checking page
echo"<script>
window.location=\"admin_order_confirm.php?Shipping_CD=$Shipping_CD&QUERY_STRING=', urlencode($querystring), '&NAMETOSHIP=$NAMETOSHIP&ADDRESSTOSHIP=$ADDRESSTOSHIP&CITYTOSHIP=$CITYTOSHIP&STATETOSHIP=$STATETOSHIP&ZIPTOSHIP=$ZIPTOSHIP&PHONETOSHIP=$PHONETOSHIP&FAXTOSHIP=$FAXTOSHIP&EMAILTOSHIP=$EMAILTOSHIP&payment_label=$payment_label&DESCRIPTION=$DESCRIPTION&userid=$userid \"
</script>
";
//At the top of the order confirm page I decode the value for use in the "Edit Information" link and elsewhere on the page
$QUERY_STRING=urldecode($QUERY_STRING);
//In the edit information link, I use the $QUERY_STRING value to go back to the order form...and ideally //populate that page with the existing $QUERY_STRING values, however when I click the link it blanks out //the previously populated values on the order form page and gives errors that it cannot basically find //the values it needs to run the various db SELECT statements
printf("<font color=black face=Verdana, Arial, Helvetica, sans-serif size=1>[ <a href=admin_order.php?QUERY_STRING=$QUERY_STRING&payment_label=$payment_label ><font color=blue>Edit Information</font></a> ]</font><br>");
I would definately appreciate any ideas that anyone had as to what logic..coding..other mistakes that I must be making...The space in form fields issue has been a significant source of problems during the development process..
I thank you in advance for any assistance you might be able to provide. Have a great day.
Mark