Hello everyone, In simple terms, this code is not working correctly. In more explained terms, I need help getting it to work with my database setup. I downloaded the code from an outside site, and I was editing it to fit my needs.
<?php
session_start();
include 'pidgey.sata';
$username=$_POST['myusername'];
$password=$_POST['mypassword'];
if(isset($_POST['login']))
{
if( empty($username) || empty($password) )
{
include 'Login.php';
}
else
{
//check if the username and password is in the database
$query = "SELECT Username,Password FROM username WHERE Username = '$username' and Password= '$password' ";
$result = mysql_query($query) or die(mysql_error());
if(mysql_num_rows($result)==0)
{
//if either username name or password doesn't exist
echo('nonexistant');
}
else{
header('Location: manageaccount.php');
//if username and password exist
if($username==admin)
{
$session_username = mysql_fetch_row($result);
$_SESSION['username'] = $session_username[0];
header("Location: Admin.php");
}
else if($username==admin2)
{
$session_username = mysql_fetch_row($result);
$_SESSION['username'] = $session_username[0];
header("Location: Admin.php");
}
else
{
$session_username = mysql_fetch_row($result);
$_SESSION['username'] = $session_username[0];
header("Location: Customer.php");
}
}
}
}
?>
The mySQL is connected via Pidgey.sata, which is just another php file that loads the connection.
This is how the database is setup.
-Root-
[Database Name] >uservice
[Table Name] >username
And inside the table you will find
Username, Password, UserID, Leafs, and IsBanned.
All I want is to see if the username and password exist, and if they match. If so, redirect to the account management page.
Thanks for any help