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 8067689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:24:22+00:00 2026-06-05T12:24:22+00:00

Hi Im trying to create a admin login. In my, mysql database, in the

  • 0

Hi Im trying to create a admin login. In my, mysql database, in the table ‘users_table’ I have the field admin and its default value = N but if it equals Y then direct it the Admin.php
here is my current code for starting a new session and I was wondering if I could put it in there so that if it does = Y then say session ‘Admin’ starts and redirects to Admin.php instead of $_SESSION[‘name’] (btw ‘name’ is field 1 in my database and field ‘admin’ is 7

    <?php
session_start();
    include ('condb.php');

   $name = $_POST ['username'];
   echo $name;
   $query ="SELECT name FROM users_table WHERE (name = '$name')" ;
   $result = mysql_query($query)
    or die (mysql_error($con)); 
 $row= mysql_num_rows($result);  
 if ($row=1){
 $_SESSION['name'] = $row[1];
  }         
    ?>
  • 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-06-05T12:24:26+00:00Added an answer on June 5, 2026 at 12:24 pm

    Apart from the obligatory SQL injection, what have you tried? This says “here is my code, fix it”. Please read a (recent) PHP + MySQL tutorial, which will point you towards PDO. Really, give it a read.

    In the meantime, something like this might work:

    $rowcount = mysql_num_rows($result);
    if ($rowcount == 1){
        $row = mysql_fetch_array($result);
        $_SESSION['name'] = $row['name'];
        if ($row['admin'] == 'Y')
        {
            $_SESSION['admin'] = $row['admin'];
            header("Location: admin.php");
            exit();
        }
    }         
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm in psql trying to create a table for a python admin. It's actually
I have a default Glassfish 3 installation and I am trying to create a
I am trying to create a list action in the admin generator. I have
I am trying to create an admin instance through my admins controller create action,
I am trying to create a Wordpress MU admin plugin, that will insert some
I am trying to create a search page, this allows the admin to search
Ok so I am trying create a login script, here I am using PHP5
Trying to create Database as follows: USE Master GO IF NOT EXISTS(SELECT [Name] FROM
I have create a new customer role SubAdmin with limited admin permission , assign
I am trying to create a login system with Zend that when a user

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.