Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Dec 2003
    Thanked 0 Times in 0 Posts

    $_POST >> form submit help

    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.


  • #2
    Super Moderator
    Join Date
    May 2002
    Perth Australia
    Thanked 101 Times in 99 Posts
    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
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts