Re: [PHP] How to send POST info without a form?
> How can I submit POST information to a php file without using an HTML form? You would try this function (from Rasmus Lerdorf) function PostToHost($host, $path, $data_to_send) { $fp = fsockopen($host,80); fputs($fp, "POST $path HTTP/1.1\n"); fputs($fp, "Host: $host\n"); fputs($fp, "Content-type: application/x-www-form-urlencoded\n"); fputs($fp, "Content-length: ".strlen($data_to_send)."\n"); fputs($fp, "Connection: close\n\n"); fputs($fp, $data_to_send); while(!feof($fp)) { echo fgets($fp, 128); } fclose($fp); } with $data_to_send = "formfield1=myfieldvalue1&formfield2=myfieldvalue2"; Regards, Philippe -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How to send POST info without a form?
hi, you can make a hidden form l like this .. form fields //in javascript you can use this myform.submit() and your form will be submited khalid _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How to send POST info without a form?
[snip] from the client end, you can't from the server end, you can use curl. ... but I want to submit the action value as a POST rather than a GET. I then have conditionals around each of my modules that check $_POST['action'] for one of three values and only print that module if that's the action I need the file to perform. Basically I'm trying to figure out how to lump this all into one file. Obviously I could split it into three files that do each of the desired actions, but I would then also have to have a fourth file which provides a front end into it, which I don't want to do and is what got me started down this path. How can I submit POST information to a php file without using an HTML form? [/snip] http://www.faqts.com/knowledge_base/view.phtml/aid/12039/fid/51 HTH! Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How to send POST info without a form?
from the client end, you can't from the server end, you can use curl. HTH Martin -Original Message- From: Chris Nielsen [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 02, 2002 3:09 PM To: [EMAIL PROTECTED] Subject: [PHP] How to send POST info without a form? I have a single php file that I want to do some different things (only one at a time, based on a conditional): display a form to the user for input submit information from (above) form to database list information in database (that has been INSERTed by the above) I want this file to be able to call itself using the following code: $input = $_SERVER['PHP_SELF']."?action=INPUT"; $list = $_SERVER['PHP_SELF']."?action=LIST"; print 'Input a new user'; print 'List all users'; but I want to submit the action value as a POST rather than a GET. I then have conditionals around each of my modules that check $_POST['action'] for one of three values and only print that module if that's the action I need the file to perform. Basically I'm trying to figure out how to lump this all into one file. Obviously I could split it into three files that do each of the desired actions, but I would then also have to have a fourth file which provides a front end into it, which I don't want to do and is what got me started down this path. How can I submit POST information to a php file without using an HTML form? TIA. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php