Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4251238
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:38:05+00:00 2026-05-21T04:38:05+00:00

Hi I made a login for a website. I made a successful one using

  • 0

Hi I made a login for a website.

I made a successful one using 1 account table in a database.

Now I made another table for another account. Both tables are different in attributes that is why I separated them.

I am having a hard time log-in the second one in by using this algorithim.

The inputted login and password come from another page using a HTML Form.

<?php
    //Start session
    session_start();

    //Include database connection details
    require_once("config.php");
    require("clean.php");

    //Array to store validation errors
    $errmsg_arr = array();

    //Validation error flag
    $errflag = false;

    //Sanitize the POST values
    $login = clean($_POST['login']);
    $password = clean($_POST['password']);

    //Input Validations
    if($login == '') {
        $errmsg_arr[] = 'Login ID missing';
        $errflag = true;
    }
    if($password == '') {
        $errmsg_arr[] = 'Password missing';
        $errflag = true;
    }

    //If there are input validations, redirect back to the login form
    if($errflag) {
        $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
        session_write_close();
        header("location: login-form.php");
        exit();
    }

    //Create query for patient
    $qry="SELECT * FROM user_info WHERE login='$login' AND password='".md5($password)."'";
    $result=mysql_query($qry);

//Check whether the query was successful or not
    if($result) {
        if(mysql_num_rows($result) == 1) {
            //Login Successful User
            session_regenerate_id();
            $user_info = mysql_fetch_assoc($result);
            $_SESSION['SESS_MEMBER_ID']  = $user_info['ID_NO'];
            $_SESSION['SESS_FIRST_NAME'] = $user_info['FNAME'];
            $_SESSION['SESS_admin']      = $user_info['admin'];
            $_SESSION['SESS_itResult']      = $user_info['itResult'];
            //print "Login a success!";
            session_write_close();
            header("location: member-index.php");
            exit();
        }
        else {
                //Create query for 
                $qry="SELECT * FROM specialist_info WHERE spec_username='$login' AND spec_password='".md5($password)."'";
                $result2=mysql_query($qry);

                //Check whether the query was successful or not
                if($result2) {

                    if(mysql_num_rows($result2) == 1) {
                        //Login Successful User

                        session_regenerate_id();
                        $specialist_info = mysql_fetch_assoc($result);
                        $_SESSION['SESS_MEMBER_ID']  = $specialist_info['spec_id'];
                        $_SESSION['SESS_FIRST_NAME'] = $specialist_info['name'];
                        $_SESSION['SESS_admin'] = 1;

                        //print "Login a success!";
                        session_write_close();
                        header("location: member-index.php");
                        exit();
                        }

                    else {
                        //Login failed
                        header("location: login-failed.php");
                        exit();
                        }
                    }
            }
    }
        else {
        die("Query failed");
    }
}
?>

I was able to log-in the first(meaning there is connection between PHP and MySQL) account however I could not in the second.

From what i follow, I could not get in this one. “if(mysql_num_rows($result2) == 1)”
I know there is data in the second table in the database because i checked it(there is MD5 yes).

Maybe my logic is wrong. Suggestions? 😀 Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T04:38:05+00:00Added an answer on May 21, 2026 at 4:38 am

    I’m not sure about the code (will review later) but you could try refactoring your tables so you have a separate table that contains user attributes, this allows you to be dynamic with your attributes so you don’t have to create a different table every time you have a different type of user.

    EDIT:
    Try:
    var_dump(mysql_num_rows($result2)) if this shows the return value is false something is wrong with the query, otherwise it doesn’t match any rows.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made a website with a login script. Now there is some guy that
I am using sessions to pass user information from one page to another. However,
I have a website made with CakePHP 1.3.7. This website has it's own login
I am using some MySQL tables. Their structures are listed below. login: loginid username
I am trying to login to a website using java.net in Google App Engine
I have a website written in-house, using a 3rd party login mechanism. Recently we've
I have a website already running made with CakePHP, which has its own login
I've made a website which has registration/login. I can see the PHPSESSID cookie in
i have made a simple login code for my program. On my website i
I'm trying to make a login page for my website I am using xampp

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.