Jump to content

Need to verify users based on three criteria


rscott7706

Recommended Posts

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:

<?php

define ('DB_USER', '');  // Database User Name
define ('DB_PASSWORD', '');    // Database User Password
define ('DB_HOST', 'localhost');  // Host Name (mostly localhost)
$dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD);  // Establishes connection
mysql_select_db('');    // database name to connect to

define(TABLE_NAME,'users'); // Table Name
define(USER_NAME,'userid'); // Username Field Name
define(PASS_NAME,'password'); // Password Field Name
define(ACTIVATED_NAME,'activated'); // Activated Field Name [color=red]<-----  added this code[/color]
?>

Then change code in my login.php page:

<?php
session_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 match
if($_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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.