hey_suburbia Posted August 10, 2006 Share Posted August 10, 2006 I have a simple form that checks to see if you're email is in the DB and if so, it redirects you.I wanted to know how to associate that email with the name field in the DB.Something like:[code]$fetch_exist=mysql_query("SELECT name FROM memberlist WHERE email = '$email'");$name = $fetch_exist;[/code]????Would that work? Quote Link to comment https://forums.phpfreaks.com/topic/17165-associate-name-field-in-db-with-email-entered/ Share on other sites More sharing options...
Ninjakreborn Posted August 10, 2006 Share Posted August 10, 2006 to check the field you can do this.[code]$select = "SELECT name FROM memberlist WHERE email = '$email';";$query = mysql_query($select);[/code]// that set's the foundation for it then..[code]if (mysql_num_rows($query)) {// if it finds something it does this.}[/code]or if you wanted vice versa[code]if (!mysql_num_rows($query)) {// if it didn't find anything it does this.}[/code]That is just to test them, if you wanted to have access to the database variables you have to use mysql_fetch_array or a similiar function, and use the variable name as the key like[code]while($row = mysql_fetch_array($select)) {// THen you access your table columns through the array. Using there names as values likeecho $row['email'];// that would print out the email address from the database.}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/17165-associate-name-field-in-db-with-email-entered/#findComment-72693 Share on other sites More sharing options...
hey_suburbia Posted August 10, 2006 Author Share Posted August 10, 2006 Thanks, that worked. I just changed it around a little and I think you had a typo, on the [code]mysql_fetch_array($select)[/code], it should be [code]mysql_fetch_array($query)[/code]No biggie, thanks![code]$select = "SELECT name FROM memberlist WHERE email = '$email';";$query = mysql_query($select);while($row = mysql_fetch_array($query)) {// THen you access your table columns through the array. Using there names as values like$row['name'];$name = $row['name'];// that would print out the email address from the database.}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/17165-associate-name-field-in-db-with-email-entered/#findComment-72699 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.