AeonE Posted March 11, 2006 Share Posted March 11, 2006 guys, I'm having some problem here, after I created my registration form (username and password fields only) using this code[quote]<?php$host = '';$uname = "root";$pass = "";$database = "db";$tablename = "login";$username = $_POST[customerId];$password = $_POST[password];$enc_pwd = md5($password);$connection = mysql_connect ($host,$uname,$pass) or die("Database connection failed, please re-check!!");$result = mysql_select_db($database) or die ("Database could not selected, please check again!!"); $query = "INSERT INTO $tablename VALUES('$username','$password')"; //change $password to $enc_pwd for encrypted password!!!$result = mysql_query($query);if (!$result){ die ("query failed, please check again <br>");} ?>[/quote] that code above is for creating new user and it works, when I go to mysql in phpmyadmin it says the password for this use is 234242hj4hj24hj.but then I created the login form, with these code[quote]<?php$host = '';$uname = "root";$pass = "";$database = "db";$tablename = "login";$username = $_POST[customerId];$password = $_POST[password];$enc_pwd = md5($password);$connection = mysql_connect ($host,$uname,$pass) or die("Database connection failed, please re-check!!");$result = mysql_select_db($database) or die ("Database could not selected, please check again!!"); $query = "SELECT * from $tablename where customerId = '$username' and password = '$enc_pwd'";$result = mysql_query($query);if ($row = mysql_fetch_array($result)){if(!$enc_pwd == $row[password]){die ("Wrong Password");}}else{die ("User not exists/password Incorrect");}?>[/quote]and it seems I could not retrieve the data from the database... it always says "User not exists/password Incorrect", checked the HTML form with the login everything are same, oh boy, it suxs I tried over over and over still no luck, maybe some1 here can help me, HELPP!!many thanks Quote Link to comment https://forums.phpfreaks.com/topic/4685-help-how-to-retrieve-data-from-database-with-encryption/ Share on other sites More sharing options...
wickning1 Posted March 11, 2006 Share Posted March 11, 2006 Your insert statement is inserting $password when it should be inserting $enc_pwd. You have a comment there that says to switch it out, but the code you posted doesn't have them switched out. Quote Link to comment https://forums.phpfreaks.com/topic/4685-help-how-to-retrieve-data-from-database-with-encryption/#findComment-16415 Share on other sites More sharing options...
AeonE Posted March 11, 2006 Author Share Posted March 11, 2006 [!--quoteo(post=353918:date=Mar 11 2006, 09:31 AM:name=wickning1)--][div class=\'quotetop\']QUOTE(wickning1 @ Mar 11 2006, 09:31 AM) [snapback]353918[/snapback][/div][div class=\'quotemain\'][!--quotec--]Your insert statement is inserting $password when it should be inserting $enc_pwd. You have a comment there that says to switch it out, but the code you posted doesn't have them switched out.[/quote]can you correct it for me, bro? cause Imma kinda new to this phpmany thanks Quote Link to comment https://forums.phpfreaks.com/topic/4685-help-how-to-retrieve-data-from-database-with-encryption/#findComment-16423 Share on other sites More sharing options...
joecooper Posted March 11, 2006 Share Posted March 11, 2006 <?php$host = '';$uname = "root";$pass = "";$database = "db";$tablename = "login";$username = $_POST[customerId];$password = $_POST[password];$enc_pwd = md5($password);$connection = mysql_connect ($host,$uname,$pass)or die("Database connection failed, please re-check!!");$result = mysql_select_db($database)or die ("Database could not selected, please check again!!");$query = "SELECT * from $tablename where customerId='$username' and password='$enc_pwd'";$result = mysql_query($query);if (mysql_num_rows($result) > 0){echo "password correct! you logged in";}else{echo "incorrect login!";}?> Quote Link to comment https://forums.phpfreaks.com/topic/4685-help-how-to-retrieve-data-from-database-with-encryption/#findComment-16435 Share on other sites More sharing options...
AeonE Posted March 11, 2006 Author Share Posted March 11, 2006 [!--quoteo(post=353940:date=Mar 11 2006, 11:07 AM:name=joecooper)--][div class=\'quotetop\']QUOTE(joecooper @ Mar 11 2006, 11:07 AM) [snapback]353940[/snapback][/div][div class=\'quotemain\'][!--quotec--]$result = mysql_query($query);if (mysql_num_rows($result) > 0){echo "password correct! you logged in";}else{echo "incorrect login!";}[/quote]still won't work, Im getting Incorrect login everytime I tried to login.I'm stuck... Quote Link to comment https://forums.phpfreaks.com/topic/4685-help-how-to-retrieve-data-from-database-with-encryption/#findComment-16439 Share on other sites More sharing options...
wickning1 Posted March 12, 2006 Share Posted March 12, 2006 The code for creating a user:[code]<?php$host = '';$uname = "root";$pass = "";$database = "db";$tablename = "login";$username = $_POST[customerId];$password = $_POST[password];$enc_pwd = md5($password);$connection = mysql_connect ($host,$uname,$pass)or die("Database connection failed, please re-check!!");$result = mysql_select_db($database)or die ("Database could not selected, please check again!!");$query = "INSERT INTO $tablename VALUES('$username','$enc_pwd')"; //change $password to $enc_pwd for encrypted password!!!$result = mysql_query($query);if (!$result){die ("query failed, please check again <br>");}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/4685-help-how-to-retrieve-data-from-database-with-encryption/#findComment-16596 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.