Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 5 of 5
  1. #1
    Member drews's Avatar
    Join Date
    Nov 2002
    Location
    St. Petersburg, Florida
    Posts
    63
    Member #
    341
    Is there a way in PHP to post variables, like the way a form would post user input. The reason I ask, is because I have made this script that, simplifies user email login and then sends it to an external PHP processor. So, right now i have the user input his name and password. Then it submits the page to my custom processor, where it adds a few custom fields and adds on a domain name to the user name. Now the only way I could think of doing this, is to have another form, post all of these variables, and then have the user click a submit button once again. It would be really nice if the user did not have to click on the second page.

    So is there a way to do this?

    Thanks!
    -drews
    -White Fiber Hosting - Coming Soon!

  2.  

  3. #2
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    You can try sending the HTTP headers manually (using the header() function).

    edit: saving the data in sessions would be better but I still haven't taken the time to figure out how yet. Others here know, though.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  4. #3
    Member drews's Avatar
    Join Date
    Nov 2002
    Location
    St. Petersburg, Florida
    Posts
    63
    Member #
    341
    Hmm. I would rather stay away from sessions, but I will look into the header() stuff.


    Thanks!
    -drews
    -White Fiber Hosting - Coming Soon!

  5. #4
    Senior Member nsr81's Avatar
    Join Date
    Oct 2002
    Posts
    1,132
    Member #
    250
    Liked
    15 times
    You will need to use fsockopen if you want to post the variables, using "POST" method. Here is the code:

    PHP Code:
    <?php
    $fp 
    fsockopen ("mydomain.com"80);

    $vars "a=1&b=2";

    $httpHeaders "POST /directory/script.php HTTP/1.1\r\n";
    $httpHeaders .= "Host: mydomain.com\r\n";
    $httpHeaders .= "Content-Length: ".strlen($vars)."\r\n";
    $httpHeaders .= "Content-Type: application/x-www-form-urlencoded\r\n";
    $httpHeaders .= "Connection: Close\r\n\r\n";
    $httpHeaders .= $vars."\r\n\r\n";

    if (
    $fp
    {
         
    fputs ($fp$httpHeaders);

         while (!
    feof($fp)) 
                   
    $data .= fgets ($fp,128);
         
    fclose ($fp);
    }
    ?>
    $data variable has the response from the other server.

    Hope that helps.

    edit: You can also perform .htaccess based authentication (user side, i.e. simulating a user entering username/password) using fsockopen. Let me know if you need that code.
    There and Back Again :Ogre:

  6. #5
    Member drews's Avatar
    Join Date
    Nov 2002
    Location
    St. Petersburg, Florida
    Posts
    63
    Member #
    341
    Ahh, thank you. I think this should work. I dont have time to test it out now, but I don't know why I didn't think of this before. I will let you know if it works.

    Thanks for your help!
    -drews
    -White Fiber Hosting - Coming Soon!


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 02:46 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com