So I made a register script and a login script for my website;
here is the register script:
<?php
$host="localhost";
$username="root";
$password="quatre";
$database="binary";
//make connection to mysql
//and store connection in the variable $con
$con=mysql_connect("localhost","root", "quatre");
if(!$con)
{
die('Could not connect'. mysqlerror());
}
mysql_select_db($database);
$aid=$_POST['aid'];
$pass=$_POST['password'];
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$phone=$_POST['phone'];
$query="SELECT * FROM users WHERE aid='$aid'";
//mysql_query() returns a result set on sucess or false on error
$result1=mysql_query($query);
$rows=mysql_num_rows($result1);
if($rows==1)
{
echo'That aid is already taken!';
}
else
{
$add="INSERT INTO users(aid,password,fname,lname,phone) VALUES('$aid','$pass','$fname','$lname', '$phone')";
$result2=mysql_query($add);
echo 'You have successfully registered!';
echo'Click <a href="login.php">here</a>to login';
}
?>
login script:
<?php
include'connect.php';
$aid=$_POST['aid'];
$pass=$_POST['password'];
//first check if that aid was registered
//or if it does not exist
$query="SELECT * FROM users WHERE aid='$aid'";
$result=mysql_query($query);
//now check number of rows in resource returned
$rows=mysql_num_rows($result);
//if resource returned contains no row
//it means that the aid was not registered
if($rows==0)
{
echo 'The aid you entered does not exist!';
}
//if the aid was registered
else
{
$arr=mysql_fetch_array($query);
//check if correct password was entered
if($arr['password']==$pass)
{
echo'You are now logged in!';
}
else
{
echo'The password/username you entered was not valid!';
}
}
?>
Now I changed my mind and the site will only allow admins to login so now I need to modify the login just to suit admin needs but my problem is since it won't be wise to build a register script for admins
how do I add new admins!
I mean do I add admins account myself and just put the login there or something like that.
Can someone help me please?