Try making this default.php
<?php
// Start the session
session_start();
if (empty($_SESSION['Username']) || !isset($_SESSION['Username'])) {
$_SESSION['Username'] = "";
$_SESSION['Access'] = 0;
}
?>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Website</title>
</head>
<body>
<table width="100%" height="100%" border="0">
<tr height="1%">
<td>
<?php require "menubar.php"; ?>
</td>
</tr>
<tr height="10%">
<td>
<?php require "logo.php"; ?>
</td>
</tr>
<tr valign="top">
<td>
<?php require "main.php"; ?>
</td>
</tr>
</table>
</body>
</html>
And this login.php
<?php
session_start();
?><html>
<body>
<?php
if(strlen($_POST['user']) == 0 || strlen($_POST['pass']) == 0)
{
echo "
<center>
<form action=\"?page=Login\" method=\"post\">
<table border=\"0\" width=\"75%\">
<tr>
<td>
Username:
</td>
<td>
<input type=\"text\" name=\"user\" />
</td>
</tr>
<tr>
<td>
Password:
</td>
<td>
<input type=\"password\" name=\"pass\" />
</td>
</tr>
<tr>
<td>
<input type=\"submit\" value=\"Login\" />
<td>
</tr>
</table>
</form>
</center>
";
}
else
{
$mysql_host = "";
$mysql_database = "";
$mysql_user = "";
$mysql_password = "";
$con = mysql_connect($mysql_host,$mysql_user,$mysql_password);
if(!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db($mysql_database,$con);
$result = mysql_query("SELECT * FROM Accounts");
while($row = mysql_fetch_array($result))
{
if($row['Username'] == $_POST['user'] && $row['Password'] == $_POST['pass'])
{
$_SESSION['Username'] = $row['Username'];
$_SESSION['Access'] = $row['Access'];
echo "<a href=?page=UserCP>You have successfully logged in click here to access User CP.</a>";
}
}
}
?>
</body>
</html>
I will have to macgyver a login tutorial which reminds me I need to upload that other video tutorial tonight. Hope that helps.
Reputation Points: 410
Solved Threads: 258
Occupation: Genius
Offline 3,004 posts
since Sep 2007