View Full Version : $_POST >> form submit help

03-20-2004, 10:47 PM
Hello everyone, l've recently stumbled upon this script, and l wanted to know what l would need to do to adapt it to submit a form such as the following:

<form method=POST action=http://www.server1.com/script1.php>

<input type="text" name="name" size="10">

<input type="password" name="password" size="8">

<input type="submit" value="submit">

Here's the script:


function HTTP_Post($URL,$data, $referrer="http://myreferrer.com") {

// parsing the given URL

// Building referrer
if($referrer=="") // if not given use this script as referrer

// making string from $data
foreach($data as $key=>$value)

// Find out which port is needed - if not given use standard (=80)

// building POST-request:
$request.="POST ".$URL_Info["path"]." HTTP/1.1\n";
$request.="Host: ".$URL_Info["host"]."\n";
$request.="Referer: $referer\n";
$request.="Content-type: application/x-www-form-urlencoded\n";
$request.="Content-length: ".strlen($data_string)."\n";
$request.="Connection: close\n";

$fp = fsockopen($URL_Info["host"],$URL_Info["port"]);
fputs($fp, $request);
while(!feof($fp)) {
$result .= fgets($fp, 128);

return $result;


How would l get the script to input the name, and password variables? what part of the script needs to be edited to have it post the form to http://www.server1.com/script1.php?

Any break downs, or explanations of the script would be greatly appreciated. Thanks for your time, and your help.


03-22-2004, 03:52 AM
the function sends whatever data you pass in your form ,so you just need to get the path right..

echo $output1;

now how the page you post to validates the data you are sending for login is unknown here, so not a clue if it would work or not