OK, I have a form on a page which uses POST to post the results to a CGI script which converts the results in to an e-mail.
I'm steadily learning PHP so eventually will attempt to do this on my own. But it's a CGI script I've been using for many years and I've found it pretty easy to configure.
There are two hidden variables that I set in this form - one is to set the location of a thanks page, once the data has been sent, and the other is the location of an error page.
Now what I'm trying to do is when someone submits the form, they go to the URL http://www.domain.com/thanks.php?var1=w ... 2=whatever
Unfortunately, when the HTML is decoded by the browser the & in the URL string is getting replaced by &
This means when the browser is redirected, it comes through into the address bar as
http://www.domain.com/thanks.php?var1=w ... 2=whatever
On the thanks.php page I'm trying to test the value of var2 using the switch and case functions, and it doesn't seem to be working.
It just displays the default: value I enter for the switch function.
Is there a way for me to do this?
Thanks in advance
problem with & in address bar string -can't get var
Moderator: General Moderators
- launchcode
- Forum Contributor
- Posts: 401
- Joined: Tue May 11, 2004 7:32 pm
- Location: UK
- Contact:
The script is in perl so I have little idea of what to look for. I've had a look on the web and it looks fairly easy to accomplish this through PHP by writing my own very simple form to e-mail script - so I think I'll have a look at that solution rather than dig around in that CGI script.
It kinda brings me on to a pretty basic question I have - which is something that I do not understand.
Where you have variables in the address bar is that data that's been sent using GET?
In my switch command, I can just use $whatever - where something in the address line is &whatever=...
But looking through some stuff on the web regarding form to e-mail people seem to access the data using $_POST['whatever']
Now obviously that is for getting the data from a form where method = post.
Say I have a link http://www.domain.com/index.php?var1=te ... est2&var3=...
On index.php, I can just call the values of var1, var2 and var3??? So the resulting PHP page already assigns that data into the variables?? Am I correct in thinking this? Or is it just using the switch function that does this?
Whereas if you have a form and use method=post, the data is not automatically done like this, and you have to manually assign the data to variables at the beginning of the script using the $_POST['var1']
I've also seen it written $HTTP_POST_VARS['var1']
Which is best? Is there a recommended syntax to use?
Am I correct in my understanding of post and get and variables?
Thanks again - sorry for my change of tack - I think this might be the easier way after all.
PHP strikes me as being easier than tracking back through an old perl script.
It kinda brings me on to a pretty basic question I have - which is something that I do not understand.
Where you have variables in the address bar is that data that's been sent using GET?
In my switch command, I can just use $whatever - where something in the address line is &whatever=...
But looking through some stuff on the web regarding form to e-mail people seem to access the data using $_POST['whatever']
Now obviously that is for getting the data from a form where method = post.
Say I have a link http://www.domain.com/index.php?var1=te ... est2&var3=...
On index.php, I can just call the values of var1, var2 and var3??? So the resulting PHP page already assigns that data into the variables?? Am I correct in thinking this? Or is it just using the switch function that does this?
Whereas if you have a form and use method=post, the data is not automatically done like this, and you have to manually assign the data to variables at the beginning of the script using the $_POST['var1']
I've also seen it written $HTTP_POST_VARS['var1']
Which is best? Is there a recommended syntax to use?
Am I correct in my understanding of post and get and variables?
Thanks again - sorry for my change of tack - I think this might be the easier way after all.
PHP strikes me as being easier than tracking back through an old perl script.