homepage Welcome to WebmasterWorld Guest from 54.161.175.231
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?
Jeremy_H




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

Hello,

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.

<?php
ifset($_GET["s"]){
header("Location: http://www.example.com/");
... set POST=$_GET["s"]; ...
}
?>

Is it possible to set the POST variable?

 

mcavic




msg:3206306
 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.

mcibor




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

why redirect?

or if you must, then try
if(isset($_GET['s']))
{
//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

cmarshall




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

Here's what I do:

<?php
$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