Link to home
Start Free TrialLog in
Avatar of ostrox
ostroxFlag for United Arab Emirates

asked on

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

ASKER CERTIFIED SOLUTION
Avatar of Michael701
Michael701
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ostrox

ASKER

thank you that solved it!