Welcome to WebmasterWorld Guest from 3.80.4.76

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

If variable sent via GET, Redirect and send variable via POST

Is this possible?

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

Preferred Member

10+ Year Member

joined:Aug 12, 2005
posts:411
votes: 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?

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 31, 2003
posts:1316
votes: 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)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Nov 26, 2003
posts:1133
votes: 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

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 21, 2005
posts: 1526
votes: 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.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members