How to send POST information

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
xudzh
Forum Commoner
Posts: 48
Joined: Sat Feb 19, 2005 6:22 pm

How to send POST information

Post by xudzh »

I have a website, which is php powered. At my frontpage, originally there's a place where users can login to several scripts, using <select> to let people choose where.

Then i use Javascript to open a new window and write a new <form>, with the right <input name=>. But since Ms windows Xp service pack 2 was released, IE doesn't allow me to use js to create a new form. So the original method doesn't work anymore. :(

I was thinking about to let a php file to handle the multi-login. But header("location: ") can only send GET information, not POST. If i use include() to include the login file of a script, the key of $_POST wouldn't be correct. And i can't modify $_POST.

Can anyone tell me how i can build that kind of script? Like redirecting the page and send POST to the new page?

Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

xudzh
Forum Commoner
Posts: 48
Joined: Sat Feb 19, 2005 6:22 pm

really confused

Post by xudzh »

First thanks for your help, but i am really confused now.
The curl_init() will initialize a new session and return a CURL handle for use with the curl_setopt(), curl_exec(), and curl_close() functions. If the optional url parameter is supplied then the CURLOPT_URL option will be set to the value of the parameter. You can manually set this using the curl_setopt() function.
I checked the 4 functions, but i really don't understand it.

For example:

Original script: login.php
$_POST['user']=="xudzh"
$_POST['pass']=='12345'

gamelogin.php:
$_POST['playername']
$_POST['password']

bbslogin.php:
$_POST['theuser']
$_POST['password']

Now login.php is running, with $_POST['user'] and ['pass'] defined. I want to login to gamelogin.php. Can you please show me how that could be done?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

$ch = curl_init();
curl_setopt($ch, CURLOPT_POSTFIELDS, 'playername=' . rawurlencode($_POST&#1111;'user']) . '&password=' . rawurlencode($_POST&#1111;'password']) );
...
xudzh
Forum Commoner
Posts: 48
Joined: Sat Feb 19, 2005 6:22 pm

Post by xudzh »

Great, it's working now. :D
Post Reply