help me logging in to another website from my php script.

Discussion in 'PHP' started by Just need it, Aug 13, 2011.

  1. #1
    First thing that I should tell you is I'm a newbie to PHP.

    so mates, I need to create a page that can accept username and password from user and then pass them to another website to check whether the user exist on that website or not.

    It is like, my page is located at "www . mywebsite . com/check.php". now when someone open this page it should ask for the username and password of another website, say, "www . anothersite . com/login.php" and when user hit the "check login" button it should then pass the username and password to "www . anothersite . com/login.php" and check if it can login using the username and password provided by the user. if the username and password is correct then it should log in to that website (www . anothersite . com) and check the real name of user.

    I can handle the most of it, but I cant find my way around that log in part. Cant get it to log into another website. Can someone help me please ?
     
    Solved! View solution.
    Just need it, Aug 13, 2011 IP
  2. ssmm987

    ssmm987 Member

    Messages:
    180
    Likes Received:
    4
    Best Answers:
    3
    Trophy Points:
    43
    #2
    It's easy if you use Curl:

    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);

    with postdata in the format: name=value&anothername=anothervalue
     
    ssmm987, Aug 13, 2011 IP
  3. Just need it

    Just need it Active Member

    Messages:
    146
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #3
    thanks much, but can you please explain it more ?
    Please explain the method to use that function and variables. Thanks. :)
     
    Just need it, Aug 13, 2011 IP
  4. #4
    If you look in the source of the site you are curling, all the input fields have names. The postdata string is just a string, containing all the inputfieldname=inputfieldvalue, joined together with a "&".

    If you want more information, php.net has got some awesome documentation on curl (http://www.php.net/manual/en/book.curl.php)
     
    ssmm987, Aug 13, 2011 IP
  5. Just need it

    Just need it Active Member

    Messages:
    146
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #5
    thank you very much. that is really helpful.
     
    Just need it, Aug 13, 2011 IP
  6. freelanceinphp

    freelanceinphp Member

    Messages:
    134
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    48
    #6
    freelanceinphp, Aug 15, 2011 IP