Access $POST data using header re-direct?
Hello, I am looking for some help with a form I am designing please.
I have a form, where a user enters their $_POST['user_id'] and their $_POST['name'].
Now whatever number they enter for their $_POST['user_id'] and hit submit on the form I use to make a URL string for examlple
Which is done using a header redirect
echo the $_POST['name'].
Is it possible without passing the name in the URL string, or is there a way around this?
Not gonna work. Why don't you simple do the search on the script the form submits to?
A session is basically a bit of memory you can read and write which php automatically saves and reads from a file on the servers hard disk. It is unique to each user and identified by a cookie.
At the top of your script BEFORE any output such as html or print statements AND in every script that use the $_SESSION array:
$_SESSION['name'] = $_POST['name'];
Likewise to access it in your next script:
$Name = $_SESSION['name'];
I'm not sure why sunfighter thinks this isn't possible..
I didn't think it would work because header('Location: search/'.$_POST['user_id']).''); just didn't make sense to me.
These are both correct.
$_POST becomes unusable. You cannot post and get. You should be dealing with post at the location where you intend to post.
$_SESSION can be populated with $_POST. So you can retrieve $_SESSION['post'] for example from the page redirected to.
The final solution doesn't deal with redirection. You can connect to the page via socketing or curl and send the POST data manually.
|All times are GMT +1. The time now is 02:03 AM.|
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.