andrw Posted June 12, 2009 Share Posted June 12, 2009 Hey there! Im andrew and I am a complete php and mysql noob. I want to learn more. my question is: if someone inputs something into a form, how do i check the same row in the mysql database? example:i go to the form and i put in a username, andrw. then the script searches for a value in the database in the column Username with a value andrw, and the script prints out the password (in the column next to andrw (password column), but in the same row). here is the picture of my question: the blue is the value entered | the red is the value that is displayed (the red is pointing to the 585878.... one, not the 5w86 one THESE VALUES ARE NOT REAL. I RANDOMLY PRESSED KEYS!!!! Quote Link to comment https://forums.phpfreaks.com/topic/161987-newbie-mysql-question/ Share on other sites More sharing options...
jxrd Posted June 12, 2009 Share Posted June 12, 2009 You just retrieve the row from the database using SELECT, and use WHERE to retrieve the right row. Here's a good tutorial - http://www.tizag.com/mysqlTutorial/mysqlselect.php Quote Link to comment https://forums.phpfreaks.com/topic/161987-newbie-mysql-question/#findComment-854705 Share on other sites More sharing options...
Ken2k7 Posted June 12, 2009 Share Posted June 12, 2009 Why are you not hashing the passwords? Quote Link to comment https://forums.phpfreaks.com/topic/161987-newbie-mysql-question/#findComment-854743 Share on other sites More sharing options...
andrw Posted June 12, 2009 Author Share Posted June 12, 2009 Why are you not hashing the passwords? This is just a test. I didn't even insert into the database using a form and PHP, I just inserted with the insert button on PHPmyadmin. I would hash on a real service. @jxrd: Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/161987-newbie-mysql-question/#findComment-854751 Share on other sites More sharing options...
andrw Posted June 12, 2009 Author Share Posted June 12, 2009 1 more problem: I am getting this response: Resource id #7 Tell me what im doing wrong. Here is a pic of my database table: My code is: <?php include "conn.php"; //database connect $incoming = $_GET['redirect']; //GET a value $original = mysql_query('SELECT * FROM redirect WHERE redirect="$incoming"') or die(mysql_error()); //stuff.... echo $original; //echo the selected value from database ?> Quote Link to comment https://forums.phpfreaks.com/topic/161987-newbie-mysql-question/#findComment-854764 Share on other sites More sharing options...
jxrd Posted June 12, 2009 Share Posted June 12, 2009 You need to use mysql_fetch_array to actually fetch the data. Read the tutorial carefully!! Quote Link to comment https://forums.phpfreaks.com/topic/161987-newbie-mysql-question/#findComment-854805 Share on other sites More sharing options...
Ken2k7 Posted June 13, 2009 Share Posted June 13, 2009 Also use mysql_real_escape_string for security purposes. Quote Link to comment https://forums.phpfreaks.com/topic/161987-newbie-mysql-question/#findComment-854864 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.