[FX.php List] [OFF] Submitting a POST automatically

Andrew Denman adenman at tmea.org
Wed Jul 8 15:22:53 MDT 2009


Bob,

I can't tell if this code does what you want it to do, but I ran across it the other day when searching for header() help.  It's posted on the php.net header() manual comments: http://us2.php.net/manual/en/function.header.php#89447

<?php
$host = "www.example.com";
$path = "/path/to/script.php";
$data = "data1=value1&data2=value2";
$data = urlencode($data);

header("POST $path HTTP/1.1\r\n" );
header("Host: $host\r\n" );
header("Content-type: application/x-www-form-urlencoded\r\n" );
header("Content-length: " . strlen($data) . "\r\n" );
header("Connection: close\r\n\r\n" );
header($data);
?>

Andrew Denman


-----Original Message-----
From: fx.php_list-bounces at mail.iviking.org [mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of Bob Patin
Sent: Wednesday, July 08, 2009 3:37 PM
To: FX.php Discussion List
Subject: [FX.php List] [OFF] Submitting a POST automatically

I've got a rather odd need on a site:

In this site, members login to the site, and are verified in the database. So far so good.

As members, they can also go to another site; to get to it, I have to use a POST to send specific variables to the 2nd site, but I only want logged-in members to be able to do so.

If they're NOT logged-in already, I'd like to have the login process page validate them, then automatically submit a FORM that I've put on the same page.

I tried using

header("location: javascript:form2.submit();");

at the end of my PHP, but it wouldn't process. So here's my question:  
is there a way for me to do this:

1. query the db, validate the user (already done this) 2. submit a form that uses a POST (can't be a GET) without user interaction

There's probably a simple way, but I haven't found it yet; thanks,

Bob Patin




More information about the FX.php_List mailing list