brvnbld Posted December 4, 2014 Author Share Posted December 4, 2014 Does this other site require a cookie or anything? You see the other site and what happens when logs in, hard to help beyond what I tried. i think it will require cookie, bcoz if i log in to that webpage this track.html on my website works very well.... thanks for the help, i heartily thank you for ur valuable time. Quote Link to comment https://forums.phpfreaks.com/topic/292885-curl-login-into-website-not-working/page/2/#findComment-1498478 Share on other sites More sharing options...
brvnbld Posted December 4, 2014 Author Share Posted December 4, 2014 is it allowed to post the website name in the forum? Quote Link to comment https://forums.phpfreaks.com/topic/292885-curl-login-into-website-not-working/page/2/#findComment-1498479 Share on other sites More sharing options...
QuickOldCar Posted December 4, 2014 Share Posted December 4, 2014 Sure, pertains to the problem at hand, although the person helping would need to be a member. There are a few examples of curl and cookies in the forum. http://forums.phpfreaks.com/index.php?app=core&module=search&do=search&fromMainBar=1 Quote Link to comment https://forums.phpfreaks.com/topic/292885-curl-login-into-website-not-working/page/2/#findComment-1498576 Share on other sites More sharing options...
brvnbld Posted December 5, 2014 Author Share Posted December 5, 2014 (edited) Sure, pertains to the problem at hand, although the person helping would need to be a member. There are a few examples of curl and cookies in the forum. http://forums.phpfreaks.com/index.php?app=core&module=search&do=search&fromMainBar=1 hi, dude, thanks for ur kind help. i found what is the problem., but couldn't find a solution. the login form in my page does not submit the data to the page on other website. i know this is too much to ask.i will post the whole page and html code with original links now. the login form on my page. index1.html <html> <head> <title></title> <link rel="stylesheet" href="styles/main.css" type="text/css" media="print, projection, screen"> </head> <body> <center> <br><br><br><br><br><br><br><br> <div style="border:1px solid #000000;background:#EEEEEE;padding-top:15px;padding-bottom:5px;width:350px;"> <font size=+2>Sign In Form</font><br> <form method=post action="http://www.bulksms2cash.com/index.php"> <input type="hidden" name="action" value="logon"> <table border=0> <tr> <td>Username:</td> <td><input name="username" type="text" size=30></td> </tr> <tr> <td>Password:</td> <td><input name="password" type="password" size=30></td> </tr> <td></td> <td align="left"><input type=submit value="Sign In"></td> </tr> <tr> <td align="center" colspan=2><font size=-1>Don't have an Account ?</font> <a href="?action=newuser"><font size=-1 color="#0000EE">Sign UP Now !</font></a></td> </tr> </table> </form> //<script> document.forms[1].submit()</script> //<script>$("#loginForm").submit();</script> </div> <br> </center> </body> </html> the html page on my website , which the user needs to see after login , track.html <html> <div style="position: absolute; left: 0px; top: 0px; border: solid 2px #555; width:594px; height:332px;"> <div style="overflow: hidden; margin-top: -100px; ;"> </div> <iframe src="http://www.bulksms2cash.com#work" scrolling="no" style="height: 800; border: 0px none; width: 1280; margin-top: -60px; ; "> </iframe> </div> </div> <body> </html> Edited December 5, 2014 by brvnbld Quote Link to comment https://forums.phpfreaks.com/topic/292885-curl-login-into-website-not-working/page/2/#findComment-1498608 Share on other sites More sharing options...
brvnbld Posted December 5, 2014 Author Share Posted December 5, 2014 I have attached their jquery file, hope it will provide a clue to what my problem is. jquery.txt Quote Link to comment https://forums.phpfreaks.com/topic/292885-curl-login-into-website-not-working/page/2/#findComment-1498609 Share on other sites More sharing options...
QuickOldCar Posted December 5, 2014 Share Posted December 5, 2014 That jquery is a lot to scour through, but since is commented out is not being used. Some things to think about. Not all sites allow remote logins as an example I block them at my sites, bogus hidden input, no direct access to the login process script, must be within a page on the site and sessions some generate fresh tokens,check referrer locations You keep having unquoted attribute values in the form method="post" type="submit" so is this your curl script page http://www.bulksms2cash.com/index.php ? the form should lead to your curl script, or keep the action blank and add the curl script same as the login form 1 Quote Link to comment https://forums.phpfreaks.com/topic/292885-curl-login-into-website-not-working/page/2/#findComment-1498613 Share on other sites More sharing options...
brvnbld Posted December 5, 2014 Author Share Posted December 5, 2014 hey thanks for the quick response, the http://www.bulksms2cash.com/index.php is not the curl script page, its the login page itself. the source code of this page is same as the login page in mine, except for the {action=""} part. They may not have stopped the remote login, bcoz another site uses the same method to login. how to add the curl script same as the login form?. Quote Link to comment https://forums.phpfreaks.com/topic/292885-curl-login-into-website-not-working/page/2/#findComment-1498618 Share on other sites More sharing options...
brvnbld Posted December 5, 2014 Author Share Posted December 5, 2014 (edited) I got it working buddy, but there is a prob associated with it. i will post the pages through which i achieved the solution. indexd.php <?php session_start(); include("passwords.php"); check_logged(); ?> logind.php <?php session_start(); include("passwords.php"); if ($_POST["ac"]=="log") { /// do after login form is submitted if ($USERS[$_POST["username"]]==$_POST["password"]) { $_SESSION["logged"]=$_POST["username"]; } else { echo 'Incorrect username/password. Please, try again.'; }; }; if (array_key_exists($_SESSION["logged"],$USERS)) { //// check if user is logged or not echo "You are logged in."; //// if user is logged show a message header('Location: track.html'); } else { //// if not logged show login form echo '<form action="http://www.bulksms2cash.com/index.php" method="post"><input type="hidden" name="ac" value="log"> '; echo 'Username: <input type="text" name="username" /><br />'; echo 'Password: <input type="password" name="password" /><br />'; echo '<input type="submit" value="Login" />'; echo '</form>'; }; ?> passwords.php <?php $USERS["username1"] = "password1"; $USERS["username2"] = "password2"; $USERS["username3"] = "password3"; function check_logged(){ global $_SESSION, $USERS; if (!array_key_exists($_SESSION["logged"],$USERS)) { header("Location: logind.php"); }; }; ?> but once the users log out from the actual site, it stops working. and btw, the track.html file is not called, it goes directly to the original site after this. Edited December 5, 2014 by brvnbld Quote Link to comment https://forums.phpfreaks.com/topic/292885-curl-login-into-website-not-working/page/2/#findComment-1498619 Share on other sites More sharing options...
QuickOldCar Posted December 5, 2014 Share Posted December 5, 2014 but once the users log out from the actual site, it stops working Seems like the correct behavior You can't pass any output to the browser before calling header, there should most likely be errors there. You have no control over an iframe Do they have a jump out of iframe or a redirect with js? You can try and parse the content instead using dom , simplexml , simplehtmldom or even preg_match the html result Have no idea what type of site it is or what it does. Quote Link to comment https://forums.phpfreaks.com/topic/292885-curl-login-into-website-not-working/page/2/#findComment-1498622 Share on other sites More sharing options...
brvnbld Posted December 5, 2014 Author Share Posted December 5, 2014 so, is it not possible to login to 1st website and view 2nd website?. but i have seen many websites allowing users to login using google,fb, etc. i just cannot understand why a simple form can't submit data to another page? Quote Link to comment https://forums.phpfreaks.com/topic/292885-curl-login-into-website-not-working/page/2/#findComment-1498647 Share on other sites More sharing options...
QuickOldCar Posted December 5, 2014 Share Posted December 5, 2014 Those sites make it to do that, websites use scripts from them. Think more on the lines of an api using OAuth https://developers.facebook.com/docs/facebook-login/v2.2 https://developers.google.com/accounts/docs/OpenIDConnect https://dev.twitter.com/web/sign-in And the passwords would be saved on the original site, not the one visiting. Instead it uses access tokens or keys On the visiting site can set a session/cookies and keep them logged in until signed out. So it doesn't just merely iframe the site, it uses an api which gets data and different ways to use the data. Quote Link to comment https://forums.phpfreaks.com/topic/292885-curl-login-into-website-not-working/page/2/#findComment-1498679 Share on other sites More sharing options...
brvnbld Posted December 6, 2014 Author Share Posted December 6, 2014 Hey thanks for everything , i have found a workaround for this, now, this is what happens, if i open the login form page on my website, after submitting data, then the original page's login form appears, but if i open the iframed page of the original site, its logged in. What i think is the page gets logged in, i mean the form is submitted, but getting redirected to the original page. Quote Link to comment https://forums.phpfreaks.com/topic/292885-curl-login-into-website-not-working/page/2/#findComment-1498709 Share on other sites More sharing options...
brvnbld Posted December 6, 2014 Author Share Posted December 6, 2014 This is the code, that works right now. earnsms.twomini.com/index1.php earnsms.twomini.com/track.html these are the links to my site, after opening the 1st link, and typing in the username and password, the track.html if opened, the site works. But the problem is after the username and password is typed , it redirects to the original page for login and password, if we disregard that and open the track.html, the site works fine. pls help me, the username is "brvnbld" the password is "mypriya" Quote Link to comment https://forums.phpfreaks.com/topic/292885-curl-login-into-website-not-working/page/2/#findComment-1498710 Share on other sites More sharing options...
QuickOldCar Posted December 6, 2014 Share Posted December 6, 2014 (edited) You are still pointing your login form to their login, and their login form goes to same page upon submit <form id="loginForm" method="post" target= "_self" action="http://www.bulksms2cash.com/index.php"> So what happened to using your own form that points to your curl script...then redirects your own site to the work form Edited December 6, 2014 by QuickOldCar Quote Link to comment https://forums.phpfreaks.com/topic/292885-curl-login-into-website-not-working/page/2/#findComment-1498717 Share on other sites More sharing options...
brvnbld Posted December 6, 2014 Author Share Posted December 6, 2014 You are still pointing your login form to their login, and their login form goes to same page upon submit <form id="loginForm" method="post" target= "_self" action="http://www.bulksms2cash.com/index.php"> So what happened to using your own form that points to your curl script...then redirects your own site to the work form i tried that only at first, somehow, the curl doesn't seem to work at all. i have tried that here... login form: www.earnsms.com/final1/index.html the curl page: www.earnsms.com/final1/login.php the iframe page: www.earnsms.com/fina1/track.html the curl doesn't seem to post data to the website at all. instead the track.html opens without logged in. Quote Link to comment https://forums.phpfreaks.com/topic/292885-curl-login-into-website-not-working/page/2/#findComment-1498719 Share on other sites More sharing options...
QuickOldCar Posted December 6, 2014 Share Posted December 6, 2014 comment out the header and echo the curl data, see whats there In browsers is built in debuggers In Firefox click tools/web Developer/Network In Chrome is the bars top right/Tools/Developer tools, click the Network tab Not that anyone cares about IE but can click F12 to get to developer tools or go to Tools which is the cog wheel (options) then Developer tools See where your script takes you Quote Link to comment https://forums.phpfreaks.com/topic/292885-curl-login-into-website-not-working/page/2/#findComment-1498721 Share on other sites More sharing options...
brvnbld Posted December 6, 2014 Author Share Posted December 6, 2014 (edited) after commenting header and echo $result, keeps displaying same page on my site . pl, click on the links i replied prev to see it, i dunno how to explain my prob. Edited December 6, 2014 by brvnbld Quote Link to comment https://forums.phpfreaks.com/topic/292885-curl-login-into-website-not-working/page/2/#findComment-1498727 Share on other sites More sharing options...
QuickOldCar Posted December 6, 2014 Share Posted December 6, 2014 Service Temporarily Unavailable Quote Link to comment https://forums.phpfreaks.com/topic/292885-curl-login-into-website-not-working/page/2/#findComment-1498748 Share on other sites More sharing options...
brvnbld Posted December 6, 2014 Author Share Posted December 6, 2014 (edited) pls, try this link http://earnsms.com/final1/index.html Edited December 6, 2014 by brvnbld Quote Link to comment https://forums.phpfreaks.com/topic/292885-curl-login-into-website-not-working/page/2/#findComment-1498750 Share on other sites More sharing options...
brvnbld Posted December 6, 2014 Author Share Posted December 6, 2014 curl doesn't work at all , i tried displaying result too, all in vain. i think this cannot be done using curl, i have tried all options with curl, is there any otherway?. this final1 folder has these files, 1. index.html 2. login.php 3. track.html for which the codes i have posted in my prev replies. the login.php is the exact curl code you told me to paste. Quote Link to comment https://forums.phpfreaks.com/topic/292885-curl-login-into-website-not-working/page/2/#findComment-1498753 Share on other sites More sharing options...
QuickOldCar Posted December 6, 2014 Share Posted December 6, 2014 I just tried it and worked fine using this code this was result once got to track.php Your SIM will be blocked if you do it will be a lot of time to enter. Allowed 2 registration per 24 hours ! Part of the problem and were being blocked? And seems to work, redirect as well made a folder called tmp to store cookies index.php <html> <head> <title></title> <link rel="stylesheet" href="styles/main.css" type="text/css" media="print, projection, screen"> </head> <body> <center> <br><br><br><br><br><br><br><br> <div style="border:1px solid #000000;background:#EEEEEE;padding-top:15px;padding-bottom:5px;width:350px;"> <font size=+2>Sign In Form</font><br> <form action="curl.php" method="post"> <input type="hidden" name="action" value="logon"> <table border=0> <tr> <td>Username:</td> <td><input name="username" type="text" size=30></td> </tr> <tr> <td>Password:</td> <td><input name="password" type="password" size=30></td> </tr> <td></td> <td align="left"><input type="submit" value="Sign In"></td> </tr> <tr> <td align="center" colspan=2><font size=-1>Don't have an Account ?</font> <a href="?action=newuser"><font size=-1 color="#0000EE">Sign UP Now !</font></a></td> </tr> </table> </form> </div> <br> </center> </body> </html> curl.php <?php if(isset($_POST['username']) && trim($_POST['username']) !=''){ $username = trim($_POST['username']); } if(isset($_POST['password']) && trim($_POST['password']) !=''){ $password = trim($_POST['password']); } if(isset($_POST['action']) && trim($_POST['action']) !=''){ $action = trim($_POST['action']); } if(isset($username) && isset($password) && isset($action)){ $url="http://www.bulksms2cash.com/index.php"; $postdata = array("username"=>$username, "password"=>$password, "action" => $action); $fields = http_build_query($postdata); //builds the query $ch = curl_init(); $cookie = tempnam('tmp','cookie'); $cookie_file_path = "tmp/"; curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); curl_setopt ($ch, CURLOPT_TIMEOUT, 60); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_REFERER, $url); curl_setopt($ch, CURLOPT_POST, count($fields)); curl_setopt($ch, CURLOPT_POSTFIELDS,$fields); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path); $result = curl_exec ($ch); curl_close($ch); header('Location: track.php'); exit(); } else { die('Parameters missing'); } ?> track.php <html> <div style="position: absolute; left: 0px; top: 0px; border: solid 2px #555; width:594px; height:332px;"> <div style="overflow: hidden; margin-top: -100px; ;"> </div> <iframe src="http://www.bulksms2cash.com#work" scrolling="no" style="height: 800; border: 0px none; width: 1280; margin-top: -60px; ; "> </iframe> </div> </div> <body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/292885-curl-login-into-website-not-working/page/2/#findComment-1498759 Share on other sites More sharing options...
brvnbld Posted December 6, 2014 Author Share Posted December 6, 2014 this is what i get dude, i have cleared all the files , and only put the files you have said in the previous reply, and i created a tmp folder too. but still am not getting it, i am posting the screen shot. Quote Link to comment https://forums.phpfreaks.com/topic/292885-curl-login-into-website-not-working/page/2/#findComment-1498767 Share on other sites More sharing options...
brvnbld Posted December 6, 2014 Author Share Posted December 6, 2014 the posted screenshot is the track.html asking for login, since it is not logged in. And btw, am very much touched by your valuable help and time, thank you so much. Quote Link to comment https://forums.phpfreaks.com/topic/292885-curl-login-into-website-not-working/page/2/#findComment-1498768 Share on other sites More sharing options...
brvnbld Posted December 7, 2014 Author Share Posted December 7, 2014 doesn't it ask for login another time?. like i have shown in image?, Quote Link to comment https://forums.phpfreaks.com/topic/292885-curl-login-into-website-not-working/page/2/#findComment-1498818 Share on other sites More sharing options...
QuickOldCar Posted December 7, 2014 Share Posted December 7, 2014 You were right, was a cached browser page, don't know, maybe they do checks their domain js upon login Quote Link to comment https://forums.phpfreaks.com/topic/292885-curl-login-into-website-not-working/page/2/#findComment-1498820 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.