I have been working on a coding problem for some pages I inherited where the values of two variables are not showing up in the URL of the next page.
The code written by the author, which is probably quite old is
"completeyourorder.php?p=" . $p . "&service=" . $service;
as far as I can tell from my research there should be at least an echo in there
“completeyourorder.php?p=” echo . $p . “&service=” . $service;
or maybe I am missing much more than that.
I’d be grateful for a bit of education on this as I am a newbie and have not been able to find an answer despite many hours of tickering and reading.
Thanks
UPDATE:
PAGE 1
<form action="send-order.php" method="post">
<p>Name<br /><input name="clientname" value="<?echo $clientname;?>" type="text" style="width: 350px;" /></p>
<p><br /><input type="hidden" name="service" value="<?
echo $_GET['service'];
?>" />
<input type="hidden" name="p" value="<?
echo $_GET['p'];
?>"
/>
<input type="submit" value="Order now" /></p>
</form>
PAGE 2
$go = "completeyourorder.php?p=" . $p . "&service=" . $service;
return header("location:$go");
Let me know if you need anything more
SOLVED:
Brilliant thanks it works! I see now that my error was assuming that I could use the variable values in the location: completeyourorder….. on page 2 without having used $_POST earlier in the code on the same page. Thanks to everyone!
You recently asked a similar question regarding $_GET vars.
In this case, it looks like you’re building a string to echo out in a link or something. So perhaps this is the what you may be experiencing: (only an example)
Where in this example you can see that you are expecting to build the $link var based on the $_GET vars “p” and “service” and if they do not exist, default to the standard set of page 1 and service of “laundry”
Obviously you would tailor this to fit your needs, but you will need to provide more info for a better, more relevant answer.
EDIT
As per your edit, the basic answer is that your form should be populating the vars for $p and $service, so the revised code would be like this:
isset is not necessary on both, but you can change that to reflect your preferred choice for verifying post data. Some just do: