yeakyau Posted April 2, 2010 Share Posted April 2, 2010 LOGIN TABLE <img alt="" height="213" src="images/the_new_inti.jpg" width="457" /> <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form name="form1" method="post" action="checklogin.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong>FOR GRADUATED / FRESH GRADUATE MEMBER LOGIN FOR ENJOY CHATTING</strong></td> </tr> <tr> <td width="78">IC</td> <td width="6">:</td> <td width="294"><input name"ic" type="text" id="ic"></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input name="password" type="text" id="password"></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Login"></td> </tr> </table> </td> </form> </tr> </table> Check login php <?php $host="mysql5.000webhost.com"; // Host name $username="a6722055_a"; // Mysql username $password="inti88"; // Mysql password $db_name="a6722055_inti"; // 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"); // username and password sent from form $ic=$_POST['ic']; $password=$_POST['password']; // To protect MySQL injection $ic = stripslashes($ic); $password = stripslashes($password); $ic = mysql_real_escape_string($ic); $password = mysql_real_escape_string($password); $sql="SELECT * FROM $tbl_name WHERE ic='ic' and password='$password'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $ic and $password, table row must be 1 row if(count==1){ // Register $myusername, $mypassword and redirect to file "home.php" session_register("ic"); session_register("password"); header("location:home.php"); } else { echo '<script type="text/javascript"> alert("Provide Wrong Username Or Password , Please TrY Again!!!"); window.location.href = "index.php"; </script>'; } ?> it's said password do not match. do not allow to login MY database here CREATE TABLE `members` ( `ic` varchar(12) collate latin1_general_ci NOT NULL, `password` varchar(10) collate latin1_general_ci NOT NULL, `name` varchar(85) collate latin1_general_ci NOT NULL, `lastname` varchar(85) collate latin1_general_ci NOT NULL, `email` varchar(100) collate latin1_general_ci NOT NULL, `gender` varchar(6) collate latin1_general_ci NOT NULL, `address` varchar(2000) collate latin1_general_ci NOT NULL, `country` varchar(100) collate latin1_general_ci NOT NULL, PRIMARY KEY (`ic`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; -- -- Dumping data for table `members` -- INSERT INTO `members` VALUES('850905075287', 'kiss', 'kiss', 'kiss', 'kiss', 'kiss', 'kiss', 'kiss'); Quote Link to comment https://forums.phpfreaks.com/topic/197323-cant-login-got-problem-with-the-code-help/ Share on other sites More sharing options...
coupe-r Posted April 2, 2010 Share Posted April 2, 2010 I see a few problems here... 1. You have your database details within your page. NO NO NO. create a separate php file with that information and just require it in all your pages. 2. I believe you have your stripslashes and mysql_real_escape_string out of order. MRES should be first. This function adds slashes if necessary, then you need to strip them. 3. $sql="SELECT * FROM $tbl_name WHERE ic='ic' and password='$password'"; You do not have a variable for ic=. it should be ic='$ic'. try that for now. Quote Link to comment https://forums.phpfreaks.com/topic/197323-cant-login-got-problem-with-the-code-help/#findComment-1035706 Share on other sites More sharing options...
yeakyau Posted April 2, 2010 Author Share Posted April 2, 2010 1. You mean i should include users detail in database? it is, than how to include users detail.. Quote Link to comment https://forums.phpfreaks.com/topic/197323-cant-login-got-problem-with-the-code-help/#findComment-1035711 Share on other sites More sharing options...
coupe-r Posted April 2, 2010 Share Posted April 2, 2010 You have this information in your php file: $host="mysql5.000webhost.com"; // Host name $username="a6722055_a"; // Mysql username $password="inti88"; // Mysql password $db_name="a6722055_inti"; // 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"); This is all very sensitive information because it tells me your database name and password. I suggest changing since you posted it here. Once a user logs in, you would assign a session variable to that user and check for the session on each of your pages. When they log out, you clear all sessions. I usually assign them their client_id ie ($_SESSION['c_id'] = $row['client_id'] Quote Link to comment https://forums.phpfreaks.com/topic/197323-cant-login-got-problem-with-the-code-help/#findComment-1035714 Share on other sites More sharing options...
yeakyau Posted April 2, 2010 Author Share Posted April 2, 2010 Hi sir, yes still have same problem , cannot login it still echo out my error msg provide wrong username or password pls try again ic=$ic changed Quote Link to comment https://forums.phpfreaks.com/topic/197323-cant-login-got-problem-with-the-code-help/#findComment-1035716 Share on other sites More sharing options...
coupe-r Posted April 2, 2010 Share Posted April 2, 2010 you have if(count==1){ it should be $count Quote Link to comment https://forums.phpfreaks.com/topic/197323-cant-login-got-problem-with-the-code-help/#findComment-1035717 Share on other sites More sharing options...
yeakyau Posted April 2, 2010 Author Share Posted April 2, 2010 ok already change to if($count==1){ but still not allow to login. Quote Link to comment https://forums.phpfreaks.com/topic/197323-cant-login-got-problem-with-the-code-help/#findComment-1035719 Share on other sites More sharing options...
coupe-r Posted April 2, 2010 Share Posted April 2, 2010 OK. Paste your code from declaring your variables to the code under $count ==1. Quote Link to comment https://forums.phpfreaks.com/topic/197323-cant-login-got-problem-with-the-code-help/#findComment-1035721 Share on other sites More sharing options...
yeakyau Posted April 2, 2010 Author Share Posted April 2, 2010 ok sir, below is the code: // username and password sent from form $ic=$_POST['ic']; $password=$_POST['password']; // To protect MySQL injection $ic = mysql_real_escape_string($ic); $password = mysql_real_escape_string($password); $ic = stripslashes($ic); $password = stripslashes($password); $sql="SELECT * FROM $tbl_name WHERE ic='$ic' and password='$password'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $ic and $password, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "home.php" session_register("ic"); session_register("password"); header("location:home.php"); } else { echo '<script type="text/javascript"> alert("Provide Wrong Username Or Password , Please TrY Again!!!"); window.location.href = "index.php"; </script>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/197323-cant-login-got-problem-with-the-code-help/#findComment-1035722 Share on other sites More sharing options...
coupe-r Posted April 2, 2010 Share Posted April 2, 2010 OK, echo out $count and see what the value is when you try to log in. Quote Link to comment https://forums.phpfreaks.com/topic/197323-cant-login-got-problem-with-the-code-help/#findComment-1035724 Share on other sites More sharing options...
yeakyau Posted April 2, 2010 Author Share Posted April 2, 2010 value is 0 Quote Link to comment https://forums.phpfreaks.com/topic/197323-cant-login-got-problem-with-the-code-help/#findComment-1035725 Share on other sites More sharing options...
coupe-r Posted April 2, 2010 Share Posted April 2, 2010 OK good. Now, echo out your input (username and password). Then, look at your DB record to see if they match. Quote Link to comment https://forums.phpfreaks.com/topic/197323-cant-login-got-problem-with-the-code-help/#findComment-1035726 Share on other sites More sharing options...
yeakyau Posted April 2, 2010 Author Share Posted April 2, 2010 hi sir, blank... it is echo $ic $password Quote Link to comment https://forums.phpfreaks.com/topic/197323-cant-login-got-problem-with-the-code-help/#findComment-1035728 Share on other sites More sharing options...
coupe-r Posted April 2, 2010 Share Posted April 2, 2010 ok, so your values are not posting. Check to make sure your text boxes are in a form and you have named them ic and password. Quote Link to comment https://forums.phpfreaks.com/topic/197323-cant-login-got-problem-with-the-code-help/#findComment-1035730 Share on other sites More sharing options...
yeakyau Posted April 2, 2010 Author Share Posted April 2, 2010 wait the command echo '$ic $password'; like this correct? Quote Link to comment https://forums.phpfreaks.com/topic/197323-cant-login-got-problem-with-the-code-help/#findComment-1035732 Share on other sites More sharing options...
coupe-r Posted April 2, 2010 Share Posted April 2, 2010 No. echo $ic; echo '<br />'; echo $password; Quote Link to comment https://forums.phpfreaks.com/topic/197323-cant-login-got-problem-with-the-code-help/#findComment-1035733 Share on other sites More sharing options...
yeakyau Posted April 2, 2010 Author Share Posted April 2, 2010 <form name="form1" method="post" action="checklogin.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong>FOR GRADUATED / FRESH GRADUATE MEMBER LOGIN FOR ENJOY CHATTING</strong></td> </tr> <tr> <td width="78">IC</td> <td width="6">:</td> <td width="294"><input name"ic" type="text" id="ic"></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input name="password" type="text" id="password"></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Login"></td> </tr> </table> </td> </form> </tr> </table> here is my login form Quote Link to comment https://forums.phpfreaks.com/topic/197323-cant-login-got-problem-with-the-code-help/#findComment-1035734 Share on other sites More sharing options...
coupe-r Posted April 2, 2010 Share Posted April 2, 2010 for now, do this <form name="form1" method="post" action=""> take out your php page. Quote Link to comment https://forums.phpfreaks.com/topic/197323-cant-login-got-problem-with-the-code-help/#findComment-1035737 Share on other sites More sharing options...
yeakyau Posted April 2, 2010 Author Share Posted April 2, 2010 only IC is blank not show out once echo . and password is show Quote Link to comment https://forums.phpfreaks.com/topic/197323-cant-login-got-problem-with-the-code-help/#findComment-1035738 Share on other sites More sharing options...
yeakyau Posted April 2, 2010 Author Share Posted April 2, 2010 ok already take out, once click submit it display out password no ic. Quote Link to comment https://forums.phpfreaks.com/topic/197323-cant-login-got-problem-with-the-code-help/#findComment-1035739 Share on other sites More sharing options...
coupe-r Posted April 2, 2010 Share Posted April 2, 2010 so IC does not echo but password echos what you entered? Quote Link to comment https://forums.phpfreaks.com/topic/197323-cant-login-got-problem-with-the-code-help/#findComment-1035740 Share on other sites More sharing options...
yeakyau Posted April 2, 2010 Author Share Posted April 2, 2010 i enter 850905075287 than password 12345 Quote Link to comment https://forums.phpfreaks.com/topic/197323-cant-login-got-problem-with-the-code-help/#findComment-1035741 Share on other sites More sharing options...
yeakyau Posted April 2, 2010 Author Share Posted April 2, 2010 sir, is there any solutions. :'( Quote Link to comment https://forums.phpfreaks.com/topic/197323-cant-login-got-problem-with-the-code-help/#findComment-1035743 Share on other sites More sharing options...
coupe-r Posted April 2, 2010 Share Posted April 2, 2010 ok for some reason, your not posting the IC variable, but it looks fine . I'm not really sure what is happening. comment out your entire PHP. Then do the following.. $id = $_POST['id']; $password = $_POST['password']; echo $id .' '. $password; Just paste that and enter your info and press submit and tell me what it echos. Quote Link to comment https://forums.phpfreaks.com/topic/197323-cant-login-got-problem-with-the-code-help/#findComment-1035745 Share on other sites More sharing options...
yeakyau Posted April 2, 2010 Author Share Posted April 2, 2010 now i need to add back the php pages? and include this code it is Quote Link to comment https://forums.phpfreaks.com/topic/197323-cant-login-got-problem-with-the-code-help/#findComment-1035746 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.