Welcome to WebmasterWorld Guest from 54.167.0.111

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

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

Is this possible?

     

Jeremy_H

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

10+ Year Member



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

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

WebmasterWorld Senior Member 10+ Year Member



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

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

WebmasterWorld Senior Member 10+ Year Member



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

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

WebmasterWorld Senior Member 10+ Year Member



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.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month