note 80683 deleted from function.http-post-fields by sobak

From: Date: Sun, 04 Dec 2016 07:23:08 +0000
Subject: note 80683 deleted from function.http-post-fields by sobak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-208071@lists.php.net to get a copy of this message
Note Submitter: wormholio at gmail dot com ---- To use POST to submit a form to a site which requires a cookie for authentication you put the cookie in the $options array. Example: <?php $auth="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; $form_url="http://pirates.spy-hill.net/forum_reply.php?thread=663"; $message = "RoboCodeDwarf now has the gold. \n\n"; $message .= "RoboCodeDwarf sez: [quote] " . fortune -s . "[/quote]\n"; $form_fields = array( 'content' => $message, 'add_signature' => 'add_it', 'submit' => 'Post reply' ); $form_files=array(); $form_options=array( 'cookies' => array( 'auth' => $auth ) ); $response = http_post_fields($form_url, $form_fields, $form_files, $form_options ); $n = preg_match("/HTTP\/1.1 302 Found/", $response, $matches); if($n<1) echo "FAILED\n"; else echo "POSTED\n"; ?>

« previous php.notes (#208071) next »