perryratcliff Posted December 30, 2010 Share Posted December 30, 2010 $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password = md5('$mypassword')"; $result=mysql_query($sql); So the user logging in should be stored in $result. The $tbl_name has a column called 'active'. How would I go about checking if $result's active was == to 1 Basically something like if $result 'active' == 1 { Thanks for the help! Link to comment https://forums.phpfreaks.com/topic/223037-name-of-a-function/ Share on other sites More sharing options...
BlueSkyIS Posted December 30, 2010 Share Posted December 30, 2010 i suggest that you first make sure your query actually worked. i have concerns.. $result=mysql_query($sql) or die(mysql_error() . " IN $sql"); Link to comment https://forums.phpfreaks.com/topic/223037-name-of-a-function/#findComment-1153149 Share on other sites More sharing options...
BlueSkyIS Posted December 30, 2010 Share Posted December 30, 2010 but once the query is successful, you could if (mysql_numrows($result) > 0) { $data = mysql_fetch_assoc($result); $active = $data['active']; echo "active: $active <br />"; } Link to comment https://forums.phpfreaks.com/topic/223037-name-of-a-function/#findComment-1153151 Share on other sites More sharing options...
Maq Posted December 30, 2010 Share Posted December 30, 2010 mysql_num_rows* Link to comment https://forums.phpfreaks.com/topic/223037-name-of-a-function/#findComment-1153154 Share on other sites More sharing options...
BlueSkyIS Posted December 30, 2010 Share Posted December 30, 2010 oops, yes, thanks! corrected code: if (mysql_num_rows($result) > 0) { $data = mysql_fetch_assoc($result); $active = $data['active']; echo "active: $active <br />"; } Link to comment https://forums.phpfreaks.com/topic/223037-name-of-a-function/#findComment-1153161 Share on other sites More sharing options...
perryratcliff Posted December 30, 2010 Author Share Posted December 30, 2010 Thanks! I just added a second if if($count==0){ $testactive="SELECT * FROM $tbl_name WHERE username='$myusername' and password = md5('$mypassword')"; $activer=mysql_query($testactive); if (mysql_num_rows($activer) == 1) { $data = mysql_fetch_assoc($activer); $active = $data['active']; if($actve==0){ echo 'Please check your email and confirm your account'; } } if (mysql_num_rows($activer) == 0) { echo 'Wrong Username or Password'; } } ?> Works great! Link to comment https://forums.phpfreaks.com/topic/223037-name-of-a-function/#findComment-1153183 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.