Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

Login script modification: Admin login only

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.
<?php
session_start();
include("connection.php");
 
$email=$_POST['email'];
$passwd=$_POST['passwd'];
 
$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'";
$result=mysql_query($sql);
 
 
$count=mysql_num_rows($result);
 
if ($count==1){
  $result_array = mysql_fetch_assoc($result); 
  foreach($result_array as $key => $value)
  $_SESSION[$key] = $value;
  
  
header("location:moveahead.php");
}
else {
header("location:wrong.php");
}
?>

Open in new window

0
ostrox
Asked:
ostrox
1 Solution
 
Michael701Commented:
first change this

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

then

if ($count==1){

to

if ($email=='admin' and $count==1){
0
 
ostroxAuthor Commented:
thank you that solved it!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now