rscott7706 Posted August 22, 2006 Share Posted August 22, 2006 I have a members only login script. It verifies the users login name and password.I want it to verify the users login name, password and that the activted field is 1 (one) not 0 (zero).Being the good little newbie I am, I dilligently looked at the code and determined I would have to add code in connect.db:<?phpdefine ('DB_USER', ''); // Database User Namedefine ('DB_PASSWORD', ''); // Database User Passworddefine ('DB_HOST', 'localhost'); // Host Name (mostly localhost)$dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD); // Establishes connectionmysql_select_db(''); // database name to connect to define(TABLE_NAME,'users'); // Table Namedefine(USER_NAME,'userid'); // Username Field Namedefine(PASS_NAME,'password'); // Password Field Namedefine(ACTIVATED_NAME,'activated'); // Activated Field Name [color=red]<----- added this code[/color]?>Then change code in my login.php page:<?phpsession_start();//site_defines$SECURED_PAGE = 'http://www.egca.org/new_site/members-only/index.php';// If the form was submited check if the username and password matchif($_POST['submitid'] == 1){ //Call the database file require_once("connect.php"); $userid = $_POST['userid']; $password = $_POST['password']; $activated = $_POST['activated']; [color=red]<---- added this code[/color] $user_query = @mysql_query("SELECT * FROM " . TABLE_NAME . " WHERE `" . USER_NAME . "`='$userid' AND `" . PASS_NAME . "`='$password' [color=red]AND `" . ACTIVATED_NAME . "`='$ACTIVATED'.>0[/color]"); [color=red]<----- added code in red[/color] if(@mysql_num_rows($user_query) > 0){ //Make sessions $_SESSION['isloged'] = 'yes'; $_SESSION['userid'] = $_POST[userid]; // Redirect to the page header("Location: $SECURED_PAGE"); exit(); } else { $message = 'Invalid username and/or password!'; }It does not work, and I am hoping someone can lead me in the right direction. Link to comment https://forums.phpfreaks.com/topic/18307-need-to-verify-users-based-on-three-criteria/ Share on other sites More sharing options...
wildteen88 Posted August 22, 2006 Share Posted August 22, 2006 Try this as the query:SELECT * FROM " . TABLE_NAME . " WHERE `" . USER_NAME . "`='$userid' AND `" . PASS_NAME . "`='$password' AND `" . ACTIVATED_NAME . "`='1'" Link to comment https://forums.phpfreaks.com/topic/18307-need-to-verify-users-based-on-three-criteria/#findComment-78626 Share on other sites More sharing options...
rscott7706 Posted August 22, 2006 Author Share Posted August 22, 2006 I have not tested thoroughly, but it seems to be working fine!!Thanks wildteen88. I will be sending a donation today or tomorrow.PHP Freaks rocks!! 8) Link to comment https://forums.phpfreaks.com/topic/18307-need-to-verify-users-based-on-three-criteria/#findComment-78635 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.