开发者

Declaring a POST variable in PHP

So I am building a web application that uses iframe submission to asynchronously submit to / pull data from an external .php service. I have a new constraint on my project that requires being able to pull a large amount of data down. Normally I would just have the external .php service redirect back to my local page wi开发者_如何学Cth the data appended to the URL as a query string, but I don't think this is safe as there is the potential to have 5,000+ character long chunks of data (not to mention that I may be pulling up to 3 "chunks" in a single request).

My question to you all, then, is how can I go about declaring a POST variable in my .php service? In addition, if I declare a POST variable will it actually make it to the page that I redirect to via Header('Location: someLocation.php'); (I have a sneaking suspicion that it will not).

If this is not the best way to approach this and there is a better way to, from a .php file, redirect to an external location with declared POST variables please let me know.

***In the past I have used javascript to append a form to an iframe page, fill out text fields with what I needed, point the form at an external page, and then submit it. This is not a viable alternative as the .php is running as a service and therefore any javascript that I place within it will not be executed as the page is never rendered by a browser.

Best regards,


Utilize session variables.
This should get you started


Update due to comments below:

You could try using cURL to send the posts


You don't "declare" a post variable within PHP. You simply submit your data via POST and retrieve it from $_POST.

If you want to dual-method your service so it can do GET and POST, you can do:

switch ($_SERVER['REQUEST_METHOD']) {
    case 'POST':
        $myvar = $_POST['myvar'];
        break;
    case 'GET':
        $myvar = $_GET['myvar'];
        break;
    default:
        die("Unsupport request method");
}

Alternatively, you can use $_REQUEST['myvar'] instead, which is a combination of GET and POST simultaneously, but it's best to use the specific superglobal you want instead of hoping things are configured correctly with _REQUEST.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜