PHP - Automatic Login To Website
Hello ,
I'm here with a problem facing with automatic login , I'm not able to login programmatically and fill the forms programatically to other website . here is the code which i have tried .
<?php
Similar TutorialsHi, I'm trying to auto login to a website(created by me ;-) ) using the curl. as I am new to this I don't know how to make this possible. following is the code I tried but this is not submitting the data in the other site. the 'usr_name' and 'password' the field names in the page "http://localhost/myproject/users/login". and I have given a print_r in that site and it is displaying Array ( [loginType] => L [step] => confirmation [usr_name] => dasd@hotmail.com [password] => test123 ) but not submitting the form. please help me.... this is the code i've tried..I got this from web... $login = "http://localhost/myproject/users/login"; $param="loginType=L&step=confirmation&usr_name=dasd@hotmail.com&password=test123"; $c = curl_init(); curl_setopt($c, CURLOPT_URL, $login); curl_setopt($c, CURLOPT_COOKIEJAR, "cookies.txt"); curl_setopt($c, CURLOPT_COOKIEFILE, "cookies.txt"); curl_setopt($c, CURLOPT_POST, 1); curl_setopt($c, CURLOPT_POSTFIELDS, $param); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1); echo curl_exec($c); thanks in advance.... is there any way to submit a form without using a submit button? I want the form to post after the user has entered a certain amount of charaters? maybe using javascript? Any help is appreciated Ant Hi, I have create a small website with a login, over the past month it has been working fine, however today I tried to login and it says incorrect password. So I go into my phpMyAdmin database and change the password with the function type as PASSWORD. I go to login again and it still doesnt work. I did however have a dummy account on the site and that does work, and the only difference I can see is the encryption of the password, the new passwords I create start with the astrix symbol (*) and the old password that works doesnt have that. I can guess im probably using the wrong encryption type, but Iv tried loads of different ones and still nothing. I have however noticed which line of code in my PHP code isnt working for the new Passwords, but I cant see a problem. I have put it below, if anyone knows what the problem is, please, please, please let me know. Code: [Select] if ($pwd === PwdHash($pass,substr($pwd,0,9))) { It fails at this point and goes strait to the else at the bottom of the if statement. Thanks Ben p.s. if you want me to post all the Login code I will happily do so. Hello, I am trying to use cURL to login to a website, but I can't seem to get it working. Website I'm trying to login to: http://www.uniquearticlewizard.com/amember/member.php Here is what their form code looks like: Code: [Select] <form name="login" method="post" action="/amember/member.php"> <table class="vedit" > <tr> <th>Username</th> <td><input type="text" name="amember_login" size="15" value="" /></td> </tr> <tr> <th>Password</th> <td><input type="password" name="amember_pass" size="15" /></td> </tr> <tr> <td colspan="2" style='padding:0px; padding-bottom: 2px;'> <input type="checkbox" name="remember_login" value="1"> <span class="small">Remember my password?</span> </td> </tr> </table> <input type="hidden" name="login_attempt_id" value="1291657877" /> <br /> <span class='button'><input type="submit" value=" Login " /></span> <span class='button'><input type="button" value=" Back " onclick="history.back(-1)" /></span> </form> As you can see they are using a javascript button to submit the form, which doesn't have a name attribute. So I'm not sure how to get around this and tell cURL to submit the form. When I Googled I found something that said just submit the other information and it will submit itself, but I'm not sure if that's right. Here is my attempt, but I just get a blank screen. I think the script is working, but something on there end is exiting out due to me not supplying a required piece of information. I'm not sure what that is though. Code: [Select] <?php set_time_limit(0); $options = array( CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => false, // don't return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle all encodings CURLOPT_USERAGENT => "spider", // who am i CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response CURLOPT_MAXREDIRS => 10, // stop after 10 redirects ); $ch = curl_init( "http://www.uniquearticlewizard.com/amember/member.php" ); curl_setopt_array( $ch, $options ); $content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch ); $header['content'] = $content; preg_match('/name="login_attempt_id" value="(.*)" \/>/', $header['content'], $form_id); $value = $form_id[1]; $ch = curl_init(); // SET URL FOR THE POST FORM LOGIN curl_setopt($ch, CURLOPT_URL, 'http://www.uniquearticlewizard.com/amember/member.php'); // ENABLE HTTP POST curl_setopt ($ch, CURLOPT_POST, 1); $data = array('amember_login' => '*****', 'amember_pass' => '*****', 'login_attempt_id' => $value, 'remember_login' => '1'); // SET POST PARAMETERS : FORM VALUES FOR EACH FIELD curl_setopt($ch, CURLOPT_POSTFIELDS, $data); // IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); # Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL # not to print out the results of its query. # Instead, it will return the results as a string return value # from curl_exec() instead of the usual true/false. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); // EXECUTE 1st REQUEST (FORM LOGIN) $store = curl_exec($ch); echo $store; curl_close ($ch); ?> They do have a form value that changes on every page refresh, it just tracks the login attempt (which is a long number). I was able to scrape that and put it in the form with the correct value. I thought adding that would successfully log me in, but apparently there is something else going on. Any help would be greatly appreciated! Hi Friends, I wanted to know how can I go about using PHP to login into an SBS company web, I know I can do it through https://usernameassword@server.com/folder using a link but i don't really want to show the login details. Can curl handle this or is there another method? Thanks Hi guys, <----- new to this forum and coding for that matter! I have a question. I have been asking around and reading up about how to make a forum with my current tools (dreamweaver/mysql/mysqlyog) for my website, and 90% of the time the answer i get is "if your asking the question, dont bother..... use mybb or some other premade forum" Which is fine, i dont mind! But know i have an issue. To get access to my website you are requierd to login before you can do anything, after login your able to use the whole site. But now if i use one of these ready made forums such as mybb or whatever users are required to make ANOTHER registration and login aswell! and me no likes this! So my question is, is there a way to make it so the forum runs off the same login used for my website? TIA Gromit I am trying to create a remote login to one website using mine. The users will need to enter their username and password on my site, and if they are registered to my website, their login credentials will be sent to another website and a page will be retrieved.
I am stuck at sending the users' data to the original site. The original site's viewsource is this..
<form 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>I have tried this code, but not works. <?php $username="username"; $password="password"; $url="http://www.example.com/index.php"; $postdata = "username=".$username."&password=".$password; $ch = curl_init(); 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_POSTFIELDS, $postdata); curl_setopt ($ch, CURLOPT_POST, 1); $result = curl_exec ($ch); header('Location: track.html'); //echo $result; curl_close($ch); ?>Any help would be appreciated, Thanks in advance. Hello! I would like to use cURL to login to the website: lockerz.com I have some code, but it doesn't seem to work: <?php // INIT CURL $ch = curl_init(); // SET URL FOR THE POST FORM LOGIN curl_setopt($ch, CURLOPT_URL, 'http://lockerz.com/auth/login'); // ENABLE HTTP POST curl_setopt ($ch, CURLOPT_POST, 1); // SET POST PARAMETERS : FORM VALUES FOR EACH FIELD curl_setopt ($ch, CURLOPT_POSTFIELDS, 'email-email=EMAIL@hotmail.com&password-password=PASSWPRD'); // IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); # Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL # not to print out the results of its query. # Instead, it will return the results as a string return value # from curl_exec() instead of the usual true/false. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); // EXECUTE 1st REQUEST (FORM LOGIN) $store = curl_exec ($ch); // SET FILE TO DOWNLOAD curl_setopt($ch, CURLOPT_URL, 'http://lockerz.com/auction'); // EXECUTE 2nd REQUEST (FILE DOWNLOAD) $content = curl_exec ($ch); // CLOSE CURL curl_close ($ch); echo $content; ?> Thank you very much if you can help! Hello, Dear all, Please help me. I have two sites and both run on separate DB, both have separate signup and login process, Now i want if any user login from any site can access both sites. There are separate session for both sites now i want to use any of the session for user authentication. Please give suggestions. Thanks, hi i need help an idea how can i separate members from admins since i dont know how to create login form i used tutorial ( http://www.youtube.com/watch?v=4oSCuEtxRK8 ) (its session login form only that i made it work other tutorials wre too old or something) how what i want to do is separate members and admins because admin need more rights to do now i have idea but dont know will it work like that what i want to do is create additional row in table named it flag and create 0 (inactive user) 1 (member) 2 (admin) will that work? and how can i create different navigation bars for users and admins? do you recommend that i use different folders to create it or just script based on session and flag? I want to upload a file automatically at any time from my home PC to a website I am developing. I can upload OK using a form with 'enctype="multipart/form-data"' but this requires manual operation to select a file and to submit the upload request. Is there a way the upload process can be made to happen with no operator present? I also want to download from the website to my PC automatically ie. download a file (as it becomes available) from the website to a specified location on my PC, without operator intervention. Help. Thanks. Hi! I have a question that I need help with. I guess almost everyone of us have played a webgame where something happends automaticly. Some examples: Attacks, resources in Travian, Tribalwars, Khan Wars ... How are these things done? Now I'm talking about automatical things that happends every second. Is there a Cron Job that every second connectes to a database and adds more resources to the player? Regards Worqy I'm trying to create a table that looks like this: 25/11/2011 28/09/2012 02/08/2013 23/12/2011 26/10/2012 30/08/2013 20/01/2012 23/11/2012 27/09/2013 17/02/2012 21/12/2012 25/10/2013 16/03/2012 18/01/2013 22/11/2013 13/04/2012 15/02/2013 20/12/2013 11/05/2012 15/03/2013 17/01/2014 08/06/2012 12/04/2013 14/02/2014 06/07/2012 10/05/2013 14/03/2014 03/08/2012 07/06/2013 11/04/2014 31/08/2012 05/07/2013 09/05/2014 Basically it formats the dates automatically every 4 weeks into 3 columns. So far, I have the following code: Code: [Select] <?php $startDate = '2011-11-25'; $columns = 3; $number_of_dates = 33; // calculate number of rows per column $rows_per_column = ceil($number_of_dates / $columns); // make your table echo "<table>\n"; //here we changed the condition to $i < $rows for($i = 0; $i < $rows_per_column; $i++) { echo "<tr>\n"; //here will run another loop for the amount of columns for($j = 0; $j < $columns; $j++) { $weekOffset = $i * 4; $nextDate = strtotime("{$startDate} +{$weekOffset} weeks"); echo "<td width = '100'>" . date('d/m/y', $nextDate) . "</td>\n"; } echo "</tr>\n"; } echo "</table>\n"; ?> Which creates the first column fine, but then repeats the same column two more times... 25/11/2011 25/11/2011 25/11/2011 23/12/2011 23/12/2011 23/12/2011 20/01/2012 20/01/2012 20/01/2012 17/02/2012 17/02/2012 17/02/2012 16/03/2012 16/03/2012 16/03/2012 13/04/2012 13/04/2012 13/04/2012 11/05/2012 11/05/2012 11/05/2012 08/06/2012 08/06/2012 08/06/2012 06/07/2012 06/07/2012 06/07/2012 03/08/2012 03/08/2012 03/08/2012 31/08/2012 31/08/2012 31/08/2012 I know that this means there is a problem with my loop resetting itself rather than continuing, but I'm not sure how to fix it. Please could someone point out my stupid mistake? Thanks Hi All, Not sure if this is the right forum or not, so here goes! Just trying to generate a sitemap using: http://www.sitemapdoc.com/Default.aspx but get the error: Quote too many automatic redirections were attempted. I've a 301.php redirect file on my site to handle redirects and contains: if (isset($map[$_SERVER['REDIRECT_URL']])) { $new_loc = 'http://' . $_SERVER['HTTP_HOST'] . $map[$_SERVER['REDIRECT_URL']]; if (isset($_SERVER['REDIRECT_QUERY_STRING'])) { $new_loc .= '?' . $_SERVER['REDIRECT_QUERY_STRING']; } header("HTTP/1.1 301 Moved Permanently"); header("Location: $new_loc"); } else { header("HTTP/1.1 301 Moved Permanently"); header("Location: ".$_SERVER['HTTP_HOST']); } Is it an issue with my 301 causing the above error or something else? Many thanks <?php $files=glob('apk/*'); foreach( $files as $file) { echo '<img scr="'.$file.'">'.basename($file).'</img><br/>'; } ?> Hi, i am still trying to learn html and php, but i am also trying to create a website which contains a registration form. I want the validation of each field of that form to be performed automatically. So using onBlur, whenever the user steps out of a textbox field, i want to execute a php function located in another file, which will check the value of the field and display a note if the value is invalid. I want to do this using as less javascript as possible. I am not sure if what i am asking is possible but if it is i would like to know the easiest way to do this. I would appreciate any help i can get. Thanks for your time. Hi Guy, First Post ..so please help! I have rows returning from a mYSQL Database which I put in a form which is php generated and im sending this form to the next page with a SUBMIT button. I want PHP/Javascript to do this automatically when the data is loaded from the MYSQL Table Ive tried fsockpen and document.form.submit() but it doesnt seem to work Any help. Thanks in Adv, Hittesh Ahuja <?php session_start(); if(isset($_POST['submit'])) { header("Location: http://localhost/PHP/brk_plan.php"); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <p> <?php require_once('connect.php'); $email=$_SESSION['email']; $query="SELECT glycemic_index.gi_id,glycemic_index.value FROM food_preference JOIN glycemic_index ON glycemic_index.gi_id=food_preference.gi_id WHERE food_preference.email='$email' and glycemic_index.value >= 55 " or die("Update not Possible"); $result=mysql_query($query); $session_array=array(); echo "<form method='post' action='brk_plan.php' name='recommend'>"; echo "<p>This area is filtered from the user's table showing values only > 55</p>"; while($row=mysql_fetch_array($result)) { echo "Instead of: ".$row[0]."-".$row[1]."<br/>"; $one=$row[0]; $one_trimmed=substr($one,2,strlen($one)-5); $one_search="%".$one_trimmed."%"; $query2="SELECT glycemic_index.gi_id,glycemic_index.value,glycemic_index.food FROM glycemic_index WHERE glycemic_index.gi_id LIKE '$one_search' AND glycemic_index.value <55 AND glycemic_index.gi_id!='$row[0]' ORDER BY RAND() LIMIT 1 "; $result2=mysql_query($query2); while($row2=mysql_fetch_array($result2)) { echo "<input type='hidden' value='$row2[2]' name='fields[]'></input>"; echo "<p>You can have ".$row2[2].": ".$row2[0]."-".$row2[1]."</p>"; } } echo "<input type='submit' name='submit' value='dikha!'></input>"; echo "</form>"; //$_SESSION['higher_gi']=$session_array; //foreach($session_array as $value) //{ // echo $value."<br/>"; //} ?> </p> <p></p> <p></p> <p></p> <p></p> <p> </p> </body> </html> I would like to have my site automatically email me about progress of users at certain times of the day. I am using PHP, but I think this is a server issue. I just need someone to point me in the right direction so I can search out the solution. Thank you. I have a MySQL database that has a list of items which gets updated everyday. The database is truncated everyday and filled back with the recent posts. After it is filled out, I need an automatic system that will send out the emails to users who have provided certain keyword. I have a search query in place that will search through those posts, but I cannot figure out the email alert part. I just want to make something similar to a new job alert... What could be the potential tools that I can use to accomplish this? Currently all my website is in php. Thanks!! |