Login script modification: Admin login only

Posted on 2009-04-21
Last Modified: 2012-06-21
I need to modify my current login script so that it only enables an administrator with the right admin credentials set to login, so basically it should only select the admin username from the members table.







$email = stripslashes($email);

$passwd = stripslashes($passwd);

$email = mysql_real_escape_string($email);

$passwd = mysql_real_escape_string($passwd);


$sql="SELECT * FROM members WHERE email='admin' and password='admin'";




if ($count==1){

  $result_array = mysql_fetch_assoc($result); 

  foreach($result_array as $key => $value)

  $_SESSION[$key] = $value;





else {




Open in new window

Question by:ostrox
    LVL 19

    Accepted Solution

    first change this

    $sql="SELECT * FROM members WHERE email='$email' and password='$passwd'";


    if ($count==1){


    if ($email=='admin' and $count==1){

    Author Comment

    thank you that solved it!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
    Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now