homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

If variable sent via GET, Redirect and send variable via POST
Is this possible?

 10:32 pm on Jan 2, 2007 (gmt 0)


I'm trying to detect weather a variable was received via POST or GET. If the method was GET, then to automatically redirect to the POST equivalent.

header("Location: http://www.example.com/");
... set POST=$_GET["s"]; ...

Is it possible to set the POST variable?



 11:06 pm on Jan 2, 2007 (gmt 0)

No, you can't just redirect to a POST form handler. But why not just handle the data, regardless of where it comes from?

If you're trying to post data to another site that you don't own, libcurl [google.com] can do it.


 12:50 pm on Jan 3, 2007 (gmt 0)

why redirect?

or if you must, then try
//use libcurl

or if you are redirecting on the same url, then you can save the get and post in session and then process it.

Hope this helps you somehow
Michal Cibor


 2:06 pm on Jan 3, 2007 (gmt 0)

Here's what I do:

$the_variable_value = $_POST['the_variable'];
if (!$the_variable_value ){
$the_variable_value = $_GET['the_variable'];

If there is a security issue, I either use a cookie, or only accept the value via $_POST.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved