mpatel Posted August 21, 2011 Share Posted August 21, 2011 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 <?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== { 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 blocks Quote Link to comment https://forums.phpfreaks.com/topic/245344-login-problem/ Share on other sites More sharing options...
voip03 Posted August 21, 2011 Share Posted August 21, 2011 Please use the code tag. Quote Link to comment https://forums.phpfreaks.com/topic/245344-login-problem/#findComment-1260107 Share on other sites More sharing options...
JasonLewis Posted August 21, 2011 Share Posted August 21, 2011 As well as that, I suggest you use better names for your variables. Also this: if($_POST) Will always be fired, you're better off using the name of your submit button in there. Example: <input type="submit" name="login" value="Log me in!" /> // Then for your if statement if(isset($_POST['login'])) Quote Link to comment https://forums.phpfreaks.com/topic/245344-login-problem/#findComment-1260110 Share on other sites More sharing options...
mpatel Posted August 21, 2011 Author Share Posted August 21, 2011 sorry to disappoint but i cant find error I Am Kinda Messed Up so i asked for expert help thank you in advance. Quote Link to comment https://forums.phpfreaks.com/topic/245344-login-problem/#findComment-1260119 Share on other sites More sharing options...
voip03 Posted August 21, 2011 Share Posted August 21, 2011 You are missing two parts 1. Submit button name 2. Submit post <?php session_start(); session_register("id_session"); session_register("password_session"); include "header.php"; include "config.php"; $a=""; $b=""; if(isset($_POST['Submit'])) // <-- if Submit ** please check the enclose link { $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 name="Submit" value="Log In"> !<-- Submit buttoon need a name --> </td></tr> </table> </form> Link for isset [url]http://php.net/manual/en/function.isset.php[/url] Quote Link to comment https://forums.phpfreaks.com/topic/245344-login-problem/#findComment-1260219 Share on other sites More sharing options...
voip03 Posted August 21, 2011 Share Posted August 21, 2011 You are missing two parts 1. Submit button name 2. Submit post <?php session_start(); session_register("id_session"); session_register("password_session"); include "header.php"; include "config.php"; $a=""; $b=""; if(isset($_POST['Submit'])) // <-- if Submit ** please check the enclose link { $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 name="Submit" value="Log In"> !<-- Submit buttoon need a name --> </td></tr> </table> </form> Link for isset http://php.net/manual/en/function.isset.php Quote Link to comment https://forums.phpfreaks.com/topic/245344-login-problem/#findComment-1260227 Share on other sites More sharing options...
mpatel Posted August 22, 2011 Author Share Posted August 22, 2011 thanks for your precious effort i tried but still it wont work :'( i cant understand this why this script dont work am i missing something Quote Link to comment https://forums.phpfreaks.com/topic/245344-login-problem/#findComment-1260445 Share on other sites More sharing options...
Muddy_Funster Posted August 22, 2011 Share Posted August 22, 2011 thanks for your precious effort i tried but still it wont work :'( i cant understand this why this script dont work am i missing something Every time you change code could you please upload your up to date code for us to see what changes have been made? Quote Link to comment https://forums.phpfreaks.com/topic/245344-login-problem/#findComment-1260452 Share on other sites More sharing options...
mpatel Posted August 22, 2011 Author Share Posted August 22, 2011 when i run test it shows the following result that i wanna show you so you can figure it out the problem. array(6) { ["__utma"]=> string(53) "55614265.351789400.1313879250.1313879250.1313879250.1" ["__utmc"]=> string( "55614265" ["__utmz"]=> string(69) "55614265.1313879250.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)" ["PHPSESSID"]=> string(32) "451adbe95069908ba81c9946ad563de9" ["acopendivids"]=> string(4) "nada" ["acgroupswithpersist"]=> string(4) "nada" } array(11) { ["refid_session"]=> NULL ["id_session"]=> NULL ["password_session"]=> NULL ["admin_session"]=> string(4) "test" ["totalusercount_session"]=> NULL ["usercount_session"]=> NULL ["sub_admin_privileges"]=> NULL ["admin"]=> array(4) { ["user_name"]=> string(7) "purvasp" ["id"]=> string(1) "1" ["name"]=> string(13) "Administrator" ["admin_mail"]=> string(25) "[email protected]" } ["adminid"]=> string(1) "1" ["intro_name"]=> string(0) "" ["error_message"]=> string(0) "" } array(0) { } muddy_funster now hope you have solution for my errors. i think youre expert after running test i got above error, you asked what code i used, i used below code to find the error reply soon with solution thank you in advance error_reporting(E_ALL); echo "<pre>"; var_dump($_COOKIE); var_dump($_SESSION); var_dump($_POST); echo "</pre>"; any member with solution are invited and their effort will be appreciated and the voip03 i need your help the most here thank you Quote Link to comment https://forums.phpfreaks.com/topic/245344-login-problem/#findComment-1260634 Share on other sites More sharing options...
Muddy_Funster Posted August 23, 2011 Share Posted August 23, 2011 The code I was asking for was the revised page that is giving you the problem, howerver, you will need to add quotes to the following: <form action=members.php method=post> // becomes <form action="members.php" method="post"> add the quotes, and then if it's still not working please post up your full revised code so we are both working off the same page (literaly). Also, if there are any errormessages or other bits of information they would be helpfull too P.S. I'm so far from being an expert it's not even on the horizon Quote Link to comment https://forums.phpfreaks.com/topic/245344-login-problem/#findComment-1260736 Share on other sites More sharing options...
mpatel Posted August 23, 2011 Author Share Posted August 23, 2011 thsnks for your reply but i am not expert as i am new to this so i didnt know much how to do this but according to me that last part with array(0) is the POST array. That means that nothing was posted to the script. When I try to use the page, it just sits there. Quote Link to comment https://forums.phpfreaks.com/topic/245344-login-problem/#findComment-1260810 Share on other sites More sharing options...
voip03 Posted August 23, 2011 Share Posted August 23, 2011 I could not worked your codes, can you split your job in to 3 or 4 Quote Link to comment https://forums.phpfreaks.com/topic/245344-login-problem/#findComment-1260830 Share on other sites More sharing options...
mpatel Posted August 23, 2011 Author Share Posted August 23, 2011 yes i can be available between 3 to 4 , do you wanna see the site demo where it stucked if you want i can upload to my server Quote Link to comment https://forums.phpfreaks.com/topic/245344-login-problem/#findComment-1260849 Share on other sites More sharing options...
voip03 Posted August 23, 2011 Share Posted August 23, 2011 ok have recived the code ? Quote Link to comment https://forums.phpfreaks.com/topic/245344-login-problem/#findComment-1260850 Share on other sites More sharing options...
Muddy_Funster Posted August 23, 2011 Share Posted August 23, 2011 seriously, going to need to see the up to date code page that you are working on. either post it up, or add it as an attachment or there's not much can be done. Quote Link to comment https://forums.phpfreaks.com/topic/245344-login-problem/#findComment-1260853 Share on other sites More sharing options...
mpatel Posted September 2, 2011 Author Share Posted September 2, 2011 i have change the script have a look <?php //Create a session session_start(); //Make a connection to the database $dbh=mysql_connect ("localhost", "", "") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db (""); include "header.php"; include "config.php"; $id=""; $password=""; //Retrieve the form elements values if (isset($_POST['id'])) $id = $_POST['id']; if (isset($_POST['password'])) { $password = $_POST['password']; } if (isset($_GET['id'])) { $id = $_GET['id']; } if (isset($_GET['password'])) { $password = $_GET['password']; } //If login is not blank retrieve id information if($id!="" || $password !="") { $query = sprintf("SELECT * FROM users WHERE userName='".$id."' AND password='".$password."'", mysql_real_escape_string($id), mysql_real_escape_string($password)); //If match found then login succeeded. Set session if($affected_rows==1) { $_SESSION['id'] = $id; print "<center>Login successful, you can redirect to another web site using header variable of php if the login is validated like know.<br>I am sure You can figure out that.</center>"; } else { //If match not found, inform the id print "<center><font color=red>Incorrect username or password or both. Try again.</fon></center>"; } } else { print "<center><b>Please Login</b></center>"; } ?> <form name="Members Login Area" action="members.php" method="post"> <table width="100%"> <tr> <td align="center" class="text">Username:</td> </tr> <tr> <td align="center" class="text"><input type="text" name="id" size="15" maxlenght="20"></td> </tr> <tr> <td align="center" class="text">Password:</td> </tr> <tr> <td align="center" class="text"> <input type="password" name="password" size="15" maxlenght="20"></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" name="Login" value="Login"></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== { 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"; ?> in this new script i am getting following error Undefined variable: affected_rows in D:\xampp\htdocs\members.php on line 34 Quote Link to comment https://forums.phpfreaks.com/topic/245344-login-problem/#findComment-1264675 Share on other sites More sharing options...
voip03 Posted September 2, 2011 Share Posted September 2, 2011 what is in line 34 Quote Link to comment https://forums.phpfreaks.com/topic/245344-login-problem/#findComment-1264680 Share on other sites More sharing options...
mpatel Posted September 2, 2011 Author Share Posted September 2, 2011 <?php //Create a session session_start(); //Make a connection to the database $dbh=mysql_connect ("localhost", "root", "7425") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("1"); include "header.php"; include "config.php"; $id=""; $password=""; //Retrieve the form elements values if (isset($_POST['id'])) $id = $_POST['id']; if (isset($_POST['password'])) { $password = $_POST['password']; } if (isset($_GET['id'])) { $id = $_GET['id']; } if (isset($_GET['password'])) { $password = $_GET['password']; } //If login is not blank retrieve id information if($id!="" || $password !="") { $query = sprintf("SELECT * FROM users WHERE userName='".$id."' AND password='".$password."'", mysql_real_escape_string($id), mysql_real_escape_string($password)); //If match found then login succeeded. Set session if($affected_rows==1) { $_SESSION['id'] = $id; print "<center>Login successful, you can redirect to another web site using header variable of php if the login is validated like know.<br>I am sure You can figure out that.</center>"; } else { //If match not found, inform the id print "<center><font color=red>Incorrect username or password or both. Try again.</fon></center>"; } } else { print "<center><b>Please Login</b></center>"; } ?> <form name="Members Login Area" action="members.php" method="post"> <table width="100%"> <tr> <td align="center" class="text">Username:</td> </tr> <tr> <td align="center" class="text"><input type="text" name="id" size="15" maxlenght="20"></td> </tr> <tr> <td align="center" class="text">Password:</td> </tr> <tr> <td align="center" class="text"> <input type="password" name="password" size="15" maxlenght="20"></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" name="Login" value="Login"></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== { 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"; ?> if($affected_rows==1) Quote Link to comment https://forums.phpfreaks.com/topic/245344-login-problem/#findComment-1264699 Share on other sites More sharing options...
voip03 Posted September 2, 2011 Share Posted September 2, 2011 before //If login is not blank retrieve id information if($id!="" || $password !=""){ $query = sprintf("SELECT * FROM users WHERE userName='".$id."' AND password='".$password."'", mysql_real_escape_string($id), mysql_real_escape_string($password)); //If match found then login succeeded. Set session if($affected_rows==1) after adding code mysql_real_escape_string($password)); $res=mysql_query($query); $affected_rows = mysql_num_rows($res); //If match found then login succeeded. Set session if($affected_rows==1) Quote Link to comment https://forums.phpfreaks.com/topic/245344-login-problem/#findComment-1264708 Share on other sites More sharing options...
mpatel Posted September 2, 2011 Author Share Posted September 2, 2011 i am getting following error Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in D:\xampp\htdocs\members.php on line 32($affected_rows =mysql_num_rows($result) <?php //Create a session session_start(); //Make a connection to the database $dbh=mysql_connect ("localhost", "", "") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("1"); include "header.php"; include "config.php"; $id=""; $password=""; //Retrieve the form elements values if (isset($_POST['id'])) $id = $_POST['id']; if (isset($_POST['password'])) { $password = $_POST['password']; } if (isset($_GET['id'])) { $id = $_GET['id']; } if (isset($_GET['password'])) { $password = $_GET['password']; } //If login is not blank retrieve id information mysql_real_escape_string($password); $result = mysql_query($query, $dbh); $affected_rows =mysql_num_rows($result); //If match found then login succeeded. Set session if($affected_rows==1) { $_SESSION['id'] = $id; print "<center>Login successful, you can redirect to another web site using header variable of php if the login is validated like know.<br>I am sure You can figure out that.</center>"; } else { //If match not found, inform the id print "<center><font color=red>Incorrect username or password or both. Try again.</fon></center>"; } } else { print "<center><b>Please Login</b></center>"; } ?> <form name="Members Login Area" action="members.php" method="post"> <table width="100%"> <tr> <td align="center" class="text">Username:</td> </tr> <tr> <td align="center" class="text"><input type="text" name="id" size="15" maxlenght="20"></td> </tr> <tr> <td align="center" class="text">Password:</td> </tr> <tr> <td align="center" class="text"> <input type="password" name="password" size="15" maxlenght="20"></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" name="Login" value="Login"></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== { 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"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/245344-login-problem/#findComment-1264745 Share on other sites More sharing options...
voip03 Posted September 2, 2011 Share Posted September 2, 2011 yes you will get this error. cox you are not quearing the db. //If login is not blank retrieve id informationif($id!="" || $password !=""){$query = sprintf("SELECT * FROM users WHERE userName='".$id."' AND password='".$password."'",mysql_real_escape_string($id),mysql_real_escape_string($password)); //If match found then login succeeded. Set session $res=mysql_query($query); $affected_rows = mysql_num_rows($res); //If match found then login succeeded. Set session if($affected_rows==1) Quote Link to comment https://forums.phpfreaks.com/topic/245344-login-problem/#findComment-1264748 Share on other sites More sharing options...
mpatel Posted September 2, 2011 Author Share Posted September 2, 2011 after applying above code i get two errors Notice: Undefined variable: query in D:\xampp\htdocs\members.php on line 31($result=mysql_query($query) Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in D:\xampp\htdocs\members.php on line 32($affected_rows = mysql_num_rows($result) <?php //Create a session session_start(); //Make a connection to the database $dbh=mysql_connect ("localhost", "", "") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("1"); include "header.php"; include "config.php"; $id=""; $password=""; //Retrieve the form elements values if (isset($_POST['id'])) $id = $_POST['id']; if (isset($_POST['password'])) { $password = $_POST['password']; } if (isset($_GET['id'])) { $id = $_GET['id']; } if (isset($_GET['password'])) { $password = $_GET['password']; } //If login is not blank retrieve id informationif($id!="" || $password !=""){$query = sprintf("SELECT * FROM users WHERE userName='".$id."' AND password='".$password."'",mysql_real_escape_string($id),mysql_real_escape_string($password)); //If match found then login succeeded. Set session $result=mysql_query($query); $affected_rows = mysql_num_rows($result); //If match found then login succeeded. Set session if($affected_rows==1) { $_SESSION['id'] = $id; print "<center>Login successful, you can redirect to another web site using header variable of php if the login is validated like know.<br>I am sure You can figure out that.</center>"; } else { //If match not found, inform the id print "<center><font color=red>Incorrect username or password or both. Try again.</fon></center>"; } ?> <form name="Members Login Area" action="members.php" method="post"> <table width="100%"> <tr> <td align="center" class="text">Username:</td> </tr> <tr> <td align="center" class="text"><input type="text" name="id" size="15" maxlenght="20"></td> </tr> <tr> <td align="center" class="text">Password:</td> </tr> <tr> <td align="center" class="text"> <input type="password" name="password" size="15" maxlenght="20"></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" name="Login" value="Login"></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== { 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"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/245344-login-problem/#findComment-1264750 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.