Jump to content


Photo

PHP cURL - How to tell if I'm successfully logged in?


  • Please log in to reply
6 replies to this topic

#1 donatastommy

donatastommy

    Member

  • Members
  • PipPip
  • 15 posts

Posted 23 September 2013 - 01:42 PM

The forum is an IPboard forum.

I am trying to find out if my login is successful. So I login with my credentials and hit submit When I hit submit, all it does is include the other site below the post fields Here is a screenshot before I hit submit:

cecea7aff4947b953ce093f4328722b4.png

 Here is a partial screenshot after I hit submit:

8a03440584c0f9385cb1faef05e11993.png

I tried entering the correct and incorrect credentials and the same thing is happening. I am not sure whether or not my login is successful or not. After I login I am planning to post in a members area.
 
Note: the message post field is not being used right now I will use that for something else, but here is my code:

 

<html>
<div>
<form method="POST">
Message: <input name="message" type="text" size="25" /></br>

Username:<input name="username" type="text" size="25" /></br>

password:<input name="password" type="password" size="25" /></br>

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

</form>
</div>
</html>

<?php

if(isset($_POST['message'])){$message= $_POST['message'];}

if(isset($_POST['username'])){$username = $_POST['username'];}
if(isset($_POST['password'])){$password = $_POST['password'];}
if(isset($_POST['submit'])){
$link = "http://site.com/index.php?section=login;
$datatopost = array (
"
auth_key" => "880ea6a14ea49e853634fbdc5015a024",
"
referer" => "http://google.com",
"ips_username" => $_POST['username'],
"ips_password" => $_POST['password'],
);

$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $link);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $datatopost);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$returndata = curl_exec($ch);
echo $returndata;
curl_close($ch);
};



?>

 

Can someone point me in the right direction? thanks


Edited by donatastommy, 23 September 2013 - 01:46 PM.


#2 jazzman1

jazzman1

    Advanced Member

  • Gurus
  • 2,654 posts
  • LocationMississauga, Canada

Posted 23 September 2013 - 02:01 PM

I'm not using cURL in php, but try to set if (curl_errno($returndata))


Edited by jazzman1, 23 September 2013 - 02:02 PM.


#3 vinny42

vinny42

    Advanced Member

  • Members
  • PipPipPip
  • 414 posts

Posted 23 September 2013 - 02:45 PM

When you submit the form the remote server will send you something that it can use to identify you by. It you don't catch that data and send it along in your next request then the server will assume that you are not logged in.

 

So you'll have to investigae how the login process works.

 

You should probably also think about what you want to do; if the remove server want's you to be able to automate the posting , wouldn't it have an API?



#4 donatastommy

donatastommy

    Member

  • Members
  • PipPip
  • 15 posts

Posted 23 September 2013 - 03:18 PM

When you submit the form the remote server will send you something that it can use to identify you by. It you don't catch that data and send it along in your next request then the server will assume that you are not logged in.

 

So you'll have to investigae how the login process works.

 

You should probably also think about what you want to do; if the remove server want's you to be able to automate the posting , wouldn't it have an API?

So you mean like cookies? How would I catch the cookies? They are randomly generated after each logon.



#5 jazzman1

jazzman1

    Advanced Member

  • Gurus
  • 2,654 posts
  • LocationMississauga, Canada

Posted 23 September 2013 - 10:08 PM

 How the users know if they successfully logged or failed? Is there some message coming from the server to them? 



#6 vinny42

vinny42

    Advanced Member

  • Members
  • PipPipPip
  • 414 posts

Posted 24 September 2013 - 01:38 AM


So you mean like cookies? How would I catch the cookies? They are randomly generated after each logon.

 

Cookies are most likely yes. Check the cURL manual, if anything can do it, it's cURL.



#7 donatastommy

donatastommy

    Member

  • Members
  • PipPip
  • 15 posts

Posted 27 September 2013 - 08:33 PM

Cookies are most likely yes. Check the cURL manual, if anything can do it, it's cURL.

Sorry I've been away for a while

so you mean like a cookie jar?






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com