PHP - Website Login Problem
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. Similar TutorialsHello ,
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 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 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 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! 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, Hello, Hi, 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.... Hi, below is the error and php that i used for my login page.
Error:
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\Sportify\admin\checkauthadmin.php on line 11 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\xampp\htdocs\Sportify\admin\checkauthadmin.php on line 11 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\Sportify\admin\checkauthadmin.php on line 12 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\xampp\htdocs\Sportify\admin\checkauthadmin.php on line 12 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\Sportify\admin\checkauthadmin.php on line 13 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\xampp\htdocs\Sportify\admin\checkauthadmin.php on line 13 Php: <?php //session_start(); $today = date(Ymd); $_SESSION[username] = $_POST['username']; $_SESSION[password] = $_POST['password']; $_SESSION[id] = $_POST['id']; $username = stripslashes($_SESSION[username]); $password = stripslashes($_SESSION[password]); $username = mysql_real_escape_string($_SESSION[username]); $password = mysql_real_escape_string($_SESSION[password]); $id = mysql_real_escape_string($_SESSION[id]); include('connection.php'); $sql_login = "SELECT id FROM admin WHERE username = '$username' and password = '$password'"; $result_login = mysql_query($sql_login); $count_login = mysql_num_rows($result_login); //$row = mysql_fetch_assoc($sql_login); if($count_login == 1) { //session_register("user_email"); //session_register("user_password"); //echo "PASS"; header("location:../admin/main_admin.php"); } else { header("location:admin_login2.php"); } exit; ?> Hello there, The problem is that my login system isn't consistent. There's an option of staying logged in, and if you check that a cookie gets created with a hash. When you visit the site again, you should be logged in automatically. But the thing is, that when you load the page, you aren't! But after a refresh you are logged in. So I'm guessing a problem in the order of things that get done... Here's the script: Code: [Select] <?php session_start(); if(isset($_COOKIE['LoginCookie'])) { $hash = $_COOKIE['LoginCookie']; mysql_select_db('database'); $sql = "SELECT all the info of the people FROM people WHERE cookie_hash = '".$hash."'"; if($result = mysql_query($sql)) { $row = mysql_fetch_array($result); if(empty($row)) { setcookie('LoginCookie','',time()-3600); } if(mysql_num_rows($result) == 1) { $_SESSION['loggedin'] = true; $_SESSION['loggedinnick'] = $row['nick']; $_SESSION['loggedinvoornaam'] = $row['voornaam']; $_SESSION['loggedinachternaam'] = $row['achternaam']; $_SESSION['loggedinid'] = $row['id']; $_SESSION['loggedintype'] = $row['type']; } } } if(isset($_POST['login'])) { if(empty($_POST['username']) || empty($_POST['wachtwoord'])) { $_SESSION['melding'] = 'ERROR'; header('Location: index.php'); exit(); } $username = CleanMyDirtyData($_POST['username']); $wachtwoord = sha1(CleanMyDirtyData($_POST['wachtwoord'])); mysql_select_db('database'); $sqlmail = mysql_query("SELECT * FROM people WHERE email='$username' AND wachtwoord = '$wachtwoord'"); $sqlnaam = mysql_query("SELECT * FROM people WHERE nick='$username' AND wachtwoord = '$wachtwoord'"); if(mysql_num_rows($sqlmail) == 1 || mysql_num_rows($sqlnaam) == 1) { if(mysql_num_rows($sqlmail) == 1) { $row = mysql_fetch_array($sqlmail); } else { $row = mysql_fetch_array($sqlnaam); } if(isset($_POST['remember'])) { $hash = sha1($username . 'Some secret thingys for your safety'); setcookie('LoginCookie',$hash,time()+30000000); mysql_query("UPDATE leden SET cookie_hash='" . $hash . "' WHERE id='" . $row['id'] . "'")or die(mysql_error()); } $_SESSION['loggedin'] = true; $_SESSION['loggedinnick'] = $row['nick']; $_SESSION['loggedinvoornaam'] = $row['voornaam']; $_SESSION['loggedinachternaam'] = $row['achternaam']; $_SESSION['loggedinid'] = $row['id']; $_SESSION['loggedintype'] = $row['type']; $_SESSION['melding'] = 'You are logged in now.'; } else { $_SESSION['melding'] = 'ERROR'; header('Location: index.php'); exit(); } } So if the checkbox that you want to stay logged in, there is no cookie made but the $_SESSION['loggedin'] is set to true. Throughout the rest of the page, this parameter is used to show either content for guests of private content for people that are logged in. BUT the problem is that if it is checked on the first page load the $_SESSION['loggedin'] doesn't seem to get set even though the cookie is set. Another slight problem with my script is that when a user logs in on another pc, the hash get's changed in the database and the user gets logged out of the site on the previous page. What is the easiest way to do that? And do you guys think this script is safe? Or do you see some holes? Thanks in advance! arbitter Hello All, I have this problem, no matter if I typed the wrong or right email and password, I always get Login failed message here is my code index.php Code: [Select] <td class="white-text">Email: <form name="form1" method="post" action="/admin/Login.php"> <label for="user"></label> <input type="text" name="email" /> </td> </tr> <tr> <td><p><strong class="white-text">Password:</strong></p> <label for="sdf"></label> <input type="password" name="password" /> <p class="sdf"><strong></strong><a href="#" class="white-link-underline"><strong></strong></a> <input type="submit" name="submit" id="submit" value="Submit" /> </p> </form> </td> Login.php Code: [Select] <?php session_start(); $con = mysql_connect("localhost","123","123"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("123", $con); if (isset($_POST['email'])) { $email = mysql_real_escape_string($_POST['email']); $password = mysql_real_escape_string($_POST['password']); //Query $results = mysql_query("SELECT * FROM users WHERE 'email' = '$email' AND password = '$password' "); if(!$result) { $_SESSION['error'] = '<span style="color: red">Login Failed. Email or Password is Incorrect <br/>'; } else { $row = mysql_fetch_assoc($results); $_SESSION['userid'] = $row['id']; $_SESSION['email'] = $email; $_SESSION['error'] = 'Login Successful<br/>. Welcome,'. $email; } mysql_close($con); } header('Location: ./index.php') ?> Good day! I have an index.php or a login page.The scenario on my webpage is when i successfully login and i accidentally press the back button the login page appear again and when i try to login again i could login again, which is not good. here is my code: <?php session_start(); if(isset($_SESSION['USER_ID'])){ exit("you can't login in again when your all ready logged!"); } //require_once 'conn.php'; $db_name="dspi"; mysql_connect("localhost", "root", "") or die("Cannot connect to server"); mysql_select_db("$db_name")or die("Cannot select DB"); $department = mysql_real_escape_string($_POST['department']); $username = mysql_real_escape_string($_POST['username']); $sql=mysql_query("SELECT `Department`, `Username` FROM `tbllogin` WHERE `Department` = '{$department}' AND Username = '{$username}'") or die(mysql_error()); $ct = mysql_num_rows($sql); if($ct == 1) { $row = mysql_fetch_assoc($sql); if($row['Department']=='Accounting') { header('location: Company.php'); } elseif($row['Department']=='Engineering') { header('location: Company.php'); } elseif($row['Department']=='Finishing_Goods') { header('location: Company.php'); } elseif($row['Department']=='HRAD') { header('location: Company.php'); } elseif($row['Department']=='MIS') { header('location:Company.php'); } elseif($row['Department']=='Packaging_and_Design') { header('location:Company.php'); } elseif($row['Department']=='Production') { header('location:Company.php'); } elseif($row['Department']=='Purchasing_Logistic') { header('location:Company.php'); } elseif($row['Department']=='QA_and_Technical') { header('location:Company.php'); } elseif($row['Department']=='Supply_Chain') { header('location:Company.php'); } else { header('location:index.php'); echo"Incorrect Username or Department"; } } ?> login system. why wont it work? Did same thing @ school it worked. this is my action page: <?php ob_start(); $host="host"; // Host name $username="user"; // Mysql username $password="pass"; // Mysql password $db_name="db"; // Database name $tbl_name="members"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Define $myusername and $mypassword $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "users/index.php" session_register("myusername"); session_register("mypassword"); header("location:users/index.php"); } else { echo "Error. Username or password incorrect. Have you <a href='#' onclick='alert()'>registered?</a>"; } ob_end_flush(); ?> It comes up with this error: Warning: session_register() [function.session-register]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\external\index.php:59) in C:\xampp\htdocs\external\action.php on line 32 Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\external\index.php:59) in C:\xampp\htdocs\external\action.php on line 32 Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\external\index.php:59) in C:\xampp\htdocs\external\action.php on line 34 If you have not registered, please click here Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively in Unknown on line 0 Hi, I had my login working and now it has stopped working. Idk why but heres the files: <?php ob_start(); include 'inc/open.php'; // Define $ip and $password $ip=$_POST['ip']; $password=$_POST['password']; // To protect MySQL injection (more detail about MySQL injection) $ip = stripslashes($ip); $password = stripslashes($password); $ip = mysql_real_escape_string($ip); $password = mysql_real_escape_string($password); $sql="SELECT * FROM status WHERE ip='$ip' and password='$password'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $ip and $password, table row must be 1 row if($count==1){ // Register $ip, $password and redirect to file "login_success.php" session_register("ip"); session_register("password"); header("location:lindex.php"); } else { echo "Wrong ip or Password"; } ob_end_flush(); ?> And then I want my index page to recognize this and do the following: <?php session_start(); include('inc/open.php'); if(session_is_registered('ip')){ echo "<h5><a href='index.php'>Home</a> | <a href='addnew.php'>Add New Sever</a> | <a href='offline.php'>View Offline Servers</a> | <a href='editserver.php'>Server CP</a></h5>"; }else{ echo "<h5><a href='index.php'>Home</a> | <a href='addnew.php'>Add New Sever</a> | <a href='offline.php'>View Offline Servers</a> | <a href='editlogin.php'>Login</a></h5>"; } ?> Thank you. Problem: the login is working and redirecting to index.php however index.php is not recognizing that user is logged on. i want help as i cant find that the reason that why registered members cant login, when user pass entered it does not process any thing any help will be appreciated Code: [Select] <?php session_start(); session_register("id_session"); session_register("password_session"); include "header.php"; include "config.php"; $a=""; $b=""; if ($_POST) { $a=trim($_POST["id"]); $b=trim($_POST["password"]); $a=str_replace("'","",$a); $b=str_replace("'","",$b); $a=str_replace("\"","",$a); $b=str_replace("\"","",$b); } if ($a=="" || $b=="") { if ($_SESSION["id_session"]=="" || $_SESSION["password_session"]=="") { ?> <form action=members.php method=post> <br><br><Center><table><tr><td colspan=2 align=center><h3>Members Login Area</h3></td></tr> <tr><td>Member's ID</td><td><input type=text name=id></td></tr> <tr><td>Password</td><td><input type=password name=password></td></tr> <tr><td> </td><td> <a href="forgot.php" onclick="doexit=false;"><font face="Verdana,Arial,Helvetica" size="1" color="#000000"><b>Forgot Your Password?</b></font></a></td></tr> <tr><td colspan=2 align=center><input type=submit value="Log In"></td></tr> </table></form> <? } else { middle(); } } else { $check=0; $id=$_POST["id"]; $rs = mysql_query("select * from members where ID='$id'"); if ($rs) { $arr=mysql_fetch_array($rs); $n2=$arr['Password']; if ($n2==$b) { $check=1; $_SESSION["id_session"]=$arr[0]; $_SESSION["password_session"]=$arr[9]; middle(); } } if ($check==0) { print "<h2>Invalid User Id or Password</h2>"; ?> <form action=members.php method=post> <br><br><Center><table><tr><td colspan=2 align=center><h3>Members Login Area</h3></td></tr> <tr><td>Member's ID</td><td><input type=text name=id></td></tr> <tr><td>Password</td><td><input type=password name=password></td></tr> <tr><td> </td><td> <a href="forgot.php" onclick="doexit=false;"><font face="Verdana,Arial,Helvetica" size="1" color="#000000"><b>Forgot Your Password?</b></font></a></td></tr> <tr><td colspan=2 align=center><input type=submit value="Log In"></td></tr> </table></form> <? } } function middle() { $id=$_SESSION["id_session"]; $rs = mysql_query("select * from members where ID=$id"); $arr=mysql_fetch_array($rs); $check=1; $id=$arr[0]; $password=$arr[9]; $name=$arr[1]; $address=$arr[2]; $city=$arr[3]; $state=$arr[4]; $zip=$arr[5]; $country=$arr[6]; $phone=$arr[7]; $email=$arr[8]; $password=$b; $paymentoption=$arr[10]; $refby=$arr[11]; $l1=$arr[12]; $l2=$arr[13]; $l3=$arr[14]; $l4=$arr[15]; $l5=$arr[16]; $l6=$arr[17]; $l7=$arr[18]; $l8=$arr[19]; $l9=$arr[20]; $l10=$arr[21]; $leader=$arr[22]; $total=$arr[23]; $unpaid=$arr[24]; $paid=$arr[25]; ?> <table border="0" width="650"> <tr> <td width="150" valign="top"> <table width="140"> <tr> <td align="left"><br><br><br><br> <ul><font face="verdana" size="1"> <a href="stats.php">Statistics</a><br><br> <a href="update_pf.php">Edit Personal Information</a><br><br> <a href="sample_e.php">Referral Code & Links</a><br><br> <a href="logout.php">Logout</a><br><br> </td></tr></table> </td> <td VALIGN="top"> <table> <tr> <td> <font face="verdana" size="3"><b> <p>Account Center</b></font></p> <br> </td> </tr> <tr> <td> <div align="center"> <table border="0" cellpadding="3" cellspacing="0" width="400"> <tr> <td colspan="2"><b> <hr><font face="Verdana, Arial, Helvetica, sans-serif" size="-1"><center> Account Details for <?echo $name;?></font></center></b><hr> </td> </tr> <tr> <td valign="center" align="left"><strong><font face="Verdana" size="-1">Total Commisions Earned: </font></strong><br></td> <td valign="center"> <font face="Verdana" size="-1">$<? echo $total;?></font><br></td> </tr> <tr> <td valign="center" align="left"><strong><font face="Verdana" size="-1">Commisions Due: </font></strong><br></td> <td valign="center"> <font face="Verdana" size="-1">$<? echo $unpaid;?></font><br></td> </tr> <tr> <td valign="center" align="left"><strong><font face="Verdana" size="-1">Commisions Paid: </font></strong><br></td> <td valign="center"> <font face="Verdana" size="-1">$<? echo $paid;?></font><br></td> </tr> <tr> <td valign="center" align="left" colspan=2> </td> </tr> <tr> <td valign="center" align="left"><strong><font face="Verdana" size="-1">Direct Referrals: </font></strong><br></td> <td valign="center"> <font face="Verdana" size="-1"><? $rsd=mysql_query("select * from members where Leader=".$id); echo mysql_num_rows($rsd); ?></font><br></td> </tr> <tr> <td valign="center" align="left" colspan=2> </td> </tr> <tr> <td valign="center" align="left" colspan=2><strong><font face="Verdana" size="3">Downline Information </font></strong><br></td> </tr> <tr> <td valign="center" align="left"><strong><font face="Verdana" size="-1">Total Downline Size: </font></strong><br></td> <td valign="center"> <font face="Verdana" size="-1"><? echo ($l1+$l2+$l3+$l4+$l5+$l6+$l7+$l8+$l9+$l10); ?></font><br></td> </tr> <tr><td colspan=2> <Table width=100%> <tr><td bgcolor=#000000><strong><font face="Verdana" size="-1" color=#ffffff>Level</font></strong></td> <td bgcolor=#000000><strong><font face="Verdana" size="-1" color=#ffffff>Number of Members</font></strong></td> </tr> <? include "config.php"; ?> <? for($i=1;$i<=$levels;$i++) { ?> <tr><td><strong><font face="Verdana" size="-1"><? echo $i; ?></font></strong></td> <td ><font face="Verdana" size="-1"> <? if($i==1) { echo $l1; } elseif($i==2) { echo $l2; } elseif($i==3) { echo $l3; } elseif($i==4) { echo $l4; } elseif($i==5) { echo $l5; } elseif($i==6) { echo $l6; } elseif($i==7) { echo $l7; } elseif($i==8) { echo $l8; } elseif($i==9) { echo $l9; } elseif($i==10) { echo $l10; } ?> </font></td> </tr> <? } ?> </table> </td></tr> <tr><td colspan=4><hr></td><tr> </table> </div> </td> </tr> </table> <font face="verdana" size="3"><b> <p>Download Center</b></font></p> <? include "download.php"; ?> </td> </tr> </table> <br><br> <? } include "footer.php"; ?> edit: added [code][/code] blocks Hey guys, I have an issue with my php code. After registering in my site, i (the user) can't login again. It displays a message: Quote The email and password combination you entered is incorrect. Code: [Select] <?php if(logged_in()) { $user_data = user_data('name'); echo 'Welcome, ', $user_data['name']; } else { ?> <form action="" method="post" > <p> Email: <input type="email" name="login_email" /> Password: <input type="password" name="login_password" /> <input type="submit" value="Log in" /> </p> </form> <?php } if (isset($_POST['login_email'], $_POST['login_password'])) { $login_email = $_POST['login_email']; $login_password = $_POST['login_password']; $errors = array(); if(empty($login_email) || empty($login_password)){ $errors[] = 'Email and password are required!'; } else { $login = login_check($login_email, $login_password); if($login === false) { $errors[] = 'The email and password combination you entered is incorrect.'; } } if(!empty($errors)) { foreach ($errors as $error) { echo $error. '<br />'; } } else { $_SESSION['user_id'] = $login; header('Location: index.php'); exit(); } } ?> And here's the function where I call check the login: Code: [Select] <?php function login_check($email, $password) { $email = mysql_escape_string($email); $login_query = mysql_query("SELECT COUNT(`user_id`) as `count`, `user_id` FROM `users` WHERE `email`='$email' AND `password`='".md5($password) ."'"); return(mysql_result($login_query, 0) == 1) ? mysql_result($login_query, 0, 'user_id') : false; echo mysql_error(); } ?> Any clue of what this could be? hi, I'm coding a website, after being away from php for a while, and there's this simple thing that's driving me crazy. I made a simple login system to test, and I have to refresh the page twice so it becomes active, and I can't figure out why. what's wrong with this code? (keep in mind that it's just a test, I plan to get username from database, send encrypted info to cookies, and all that, but after I get this working) Code: [Select] <?php if (isset($_POST['submitlogin'])) { if ((($_POST['username'])&&($_POST['password']))=="admin") { setcookie("user", "Administrator", time()+3600); } else { $loginerror="1"; } } if (isset($_GET['logout'])) { setcookie("user", "", time()-3600); } ?> <html> <head> </head> <body> <?php if (isset($_COOKIE['user'])) { echo "Hello, ".$_COOKIE['user']; ?> <br /><a href="?logout=yes">Logout</a> <?php }else{?> <form action="" method="post"> <input name="username" type="text" /><br /> <input name="password" type="password" /><br /> <input name="submitlogin" type="submit" value="Login" /> </form> <?php }?> </body> </html> thanks for any help! Hi I want to make a simple login system which goes like this: a) the 1st page (login_form.php) will check if you are logged or not and give you the login form (username - password) b) when you submit a 2nd page (login_check) will check if you really typed anything . If it finds that the texts are null it will return you to the 1st page (without you pressing anything) and give you the form again with a error message written say above. Else it checks the mysql database.(on another page i think) i find it difficult to navigate through the pages cause header gives me error (headers allready sent) and meta tag doesnt keep the $_POST values. (for example the error meassage) Please help Sorry for my English it's not my native. |