DarkWolfXP Posted July 1, 2006 Share Posted July 1, 2006 Hello this is my first post on this forum...Here it go!Ok I encrypted my password on the page Register.phpIn login.php I made script to encrypt the password and then look if does match or not with the DatabaseMy problem is there they match but that not working well[quote]<?include "configuration.php";$db = mysql_connect($host, $login_php, $password);$basedados = mysql_select_db($database);$pass = md5($pass);$check = mysql_query("SELECT * FROM `$table` WHERE login = '$login' AND pass = '$pass'", $db);$count = mysql_num_rows($check); if ( $count == 1 ) { echo "Welcome User"; } else { echo "Login fail";}?>[/quote]when I do echo "$count"; give me always 0 with the passwordWhat I am doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/13416-md5-login-page-problem-help-plz/ Share on other sites More sharing options...
toplay Posted July 1, 2006 Share Posted July 1, 2006 You forgot the dollar sign in front of the count variable on the "if" statement:if ( count == 1 ) {Do something like:$sql = "SELECT * FROM `$table` WHERE login = '$login' AND pass = '$pass'";$check = mysql_query($sql, $db);if (!$check) { echo 'SQL: ', $sql, ' Error: ', mysql_error(); exit;}$count = mysql_num_rows($check);if (1 == $count) { echo "Welcome User";} else { echo "Login fail";}I assume all the other variables used are populated prior to this code is executed.hth.} Quote Link to comment https://forums.phpfreaks.com/topic/13416-md5-login-page-problem-help-plz/#findComment-51786 Share on other sites More sharing options...
DarkWolfXP Posted July 2, 2006 Author Share Posted July 2, 2006 Srry my mistake copying the script it got the dollar symbol in countI tried that script u told me to try to make something like that still give me 0 this is "login Fail"but if I try dont encrypt and copy the password from the phpmyadmin and paste on password form and login with the username it show "Welcome user"Thats anoying -.-'P.S can any1 explain how the guy from tutorial defined the string $login $pass? I am following a tutorial and somebody asked me what are $login and $pass defined to :sP.S $login and $pass are defined to their text field but I dont see how he did that :o Quote Link to comment https://forums.phpfreaks.com/topic/13416-md5-login-page-problem-help-plz/#findComment-51905 Share on other sites More sharing options...
toplay Posted July 2, 2006 Share Posted July 2, 2006 [quote author=DarkWolfXP link=topic=99141.msg390395#msg390395 date=1151827042]Srry my mistake copying the script it got the dollar symbol in countI tried that script u told me to try to make something like that still give me 0 this is "login Fail"but if I try dont encrypt and copy the password from the phpmyadmin and paste on password form and login with the username it show "Welcome user"Thats anoying -.-'P.S can any1 explain how the guy from tutorial defined the string $login $pass? I am following a tutorial and somebody asked me what are $login and $pass defined to :sP.S $login and $pass are defined to their text field but I dont see how he did that :o[/quote]I assume $login and $pass variables are supposed to be populated from a HTML form. The tutorial you're looking at is probably is relying on a php.ini configuration setting called register_globals. With register_globals on, PHP will automatically create variables by the same name as defined in the HTML form. This is old style of coding and has security risk implications. You should have register_globals turned off and program accordingly.For instance, if your HTML form is using a GET method, then use $_GET to access the form values. The example below assumes the POST method was used.$login = isSet($_POST['login']) ? $_POST['login'] : '';$pass = isSet($_POST['pass']) ? md5($_POST['pass']) : ''; Quote Link to comment https://forums.phpfreaks.com/topic/13416-md5-login-page-problem-help-plz/#findComment-51988 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.