Hi,
was just wondering if anyone could help me with this code, Im doing a login page and my php script for a successful login doesnt work for me.Can any1 spot something I’ve missed? my database is “users” and the tables I need in it are admin and members.
[code=php]successlogin.php
<?php
//Connect to server and select database.
$mysqli = mysqli_connect(“$host”, “$username”,”$password”,”$db_name”) or die(“connection was unsuccessful”);
mysql_select_db(“$db_name”)or die(“Database connection was unsuccessful”);
//Users Database settings
$host=”localhost”;
$username=”root”;
$password=””;
$db_name=”users”;
//User database tables needed.
$tbl_memb=”members”;
$tbl_admin=”admin”;
//create and issue the query
$username=$_POST[‘USERNAME’];
$password=$_POST[‘PASSWORD’];
$sql=”SELECT * FROM tbl_memb WHERE
username = ‘”.$_POST[“USERNAME”].”‘ AND password = PASSWORD(‘”.$_POST[“PASSWORD”].”‘)”;
$resultmemb= mysqli_query($sqlmemb) or die(mysqli_error($mysqli));
//get the number of rows in the result set; should be 1 if theres a match
isset1=mysqli_num_rows($resultmembs);
$sql=”SELECT * FROM tbl_memb WHERE
username = ‘”.$_POST[“USERNAME”].”‘ AND password = PASSWORD(‘”.$_POST[“PASSWORD”].”‘)”;
$resultadmin= mysqli_query($sqladmin) or die(mysqli_error($mysqli));
//get the number of rows in the result set; should be 1 if theres a match
isset2=mysqli_num_rows($resultadmins);
//————//
//member login//
//————//
//If isset1(members login) is equal to 1 then the members homestart page is opened
if((isset1==1)
{
?>
<script language=”javascript”>
window.open(‘../Login/homestart.htm’,”,
config=’scrollbars=yes,menubar=no,height=850,width=955,resizable=yes,status=yes’)</script>
<?php
//create display string
$display_block=” <p> “.$username.” is authorised!</p>”;
include ‘Login.html’;
}
//———–//
//admin Login//
//———–//
else
if ($isset2==1) //If admin details are correct then it will open the administrators homestart page is opened.
{
?>
<script language=”javascript”>
window.open(‘../admin/homestart.htm’,”,
config=’scrollbars=yes,menubar=no,height=850,width=955,resizable=yes,status=yes’)</script>
<?php
//create display string
$display_block=” <p> “.$username.” is authorised!”</p>”;
include ‘Login.html’;
}
//————//
//Redirection//
//———–//
else
if ($isset1==0 OR $isset2==0)//If the username enters wrong details then an error is displayed
// and they are redirected back to the login page.
echo ‘<html>’.”n”.
‘<body><div class=”error”>Sorry, the Username and password you have entered are incorrect!</div>’.”nn”.'</body>’.”n”.'</html>’;
include ‘Login.html’;
exit;
}
//set authorisation cookie
setcookie(“auth”, “1”, 0, “/”,”Login.html”, 0);
?>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title>successlogin.php</title>
</head>
<body>
<?php echo “$display_block”;?>
</body>
</html>