<?php
$_POST['username'] = $username;
$_POST['password'] = $password;
$server = 'secure.php';
$emailaddress = 'myemail'; //your personal email address
$siteemail = 'site@localhost'; //the websites email address
$serveraddress = 'localhost'; // location of the server you are connecting to
$databaseusername = '***'; // username of the database you are accessing
$databasepassword = '***'; // password of the database you are accessing
$databasename = '***'; // name of the database you are acessing
$databaseactive = '1'; // whether to access database or not
if ($databaseactive == '1') {
$con = mysql_connect($serveraddress,$databaseusername,$databasepassword);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db($databasename, $con) or die('Could connect to database');
$userinfo = mysql_query ("select `Password` from `Admin` where ID = 1");
$user = mysql_fetch_object ($userinfo);
}
else {
}
$header = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
-->
</style>
</head>
<body>';
$footer = '</body>
</html>';
$page;
if ($page == 'forgot') {
$user->Username;
echo $header;
echo 'if you have forgotten you password or username please <a href="';
echo $server;
echo '?page=sendpass">click here</a> to have it send to you email address.';
echo $footer;
}
elseif ($page == 'sendpass') {
$subject = "Forgotted Username / Password";
$message = $user . " " . $pass ;
$headers = "From: $siteemail";
mail($emailaddress,$subject,$message,$headers);
echo $header;
echo 'Your Username and Password have been emailed to your selected inbox.<br/>';
echo 'To return to the login page <a href="';
echo $server;
echo '">click here</a>';
echo $footer;
}
else {
if(!isset($_COOKIE["account"])) {
if(!isset($username)) {
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
-->
</style>
</head>
<body>
<form action="';
echo $server;
echo '" method="post" name="" class="style1" id="">
<label for="username">
<div align="center">username: </div>
</label>
<div align="center">
<input type="text" name="username" id="username" />
</div>
<label for="textfield">
<div align="center">password: </div>
</label>
<div align="center">
<input type="password" name="password" id="password" />
<br/>
<input type="submit" name="Submit" value="Submit" id="Submit" />
</div>
<div align="center">Forgotten your password? <a href="';
echo $server;
echo '?page=forgot">Click here</a></div>
</form>
</body>
</html>';
}
else {
if ($username == $user) {
if ($password == $pass) {
setcookie("account", $user, time()+3600);
echo $header;
echo 'you are now logged in<br/><a href="';
echo $server;
echo '">Click here</a> to use website';
echo $footer;
}
else {
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
-->
</style>
</head>
<body>
<div style="width:100%; height:20px; padding:4px; text-align:center; color:#ffffff; font-weight:bold; background-color:#E3170D; margin-bottom:20px;">the password you entered was incorrect, please try again</div>
<form action="';
echo $server;
echo '" method="post" name="" class="style1" id="">
<label for="username">
<div align="center">username: </div>
</label>
<div align="center">
<input type="text" name="username" id="username" />
</div>
<label for="textfield">
<div align="center">password: </div>
</label>
<div align="center">
<input type="password" name="password" id="password" />
<br/>
<input type="submit" name="Submit" value="Submit" id="Submit" />
</div>
<div align="center">Forgotten your password? <a href="';
echo $server;
echo '?page=forgot">Click here</a></div>
</form>
</body>
</html>';
}
}
else {
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
-->
</style>
</head>
<body>
<div style="width:100%; height:20px; padding:4px; text-align:center; color:#ffffff; font-weight:bold; background-color:#E3170D; margin-bottom:20px;">the username you entered was incorrect, please try again</div>
<form action="';
echo $server;
echo '" method="post" name="" class="style1" id="">
<label for="username">
<div align="center">username: </div>
</label>
<div align="center">
<input type="text" name="username" id="username" />
</div>
<label for="textfield">
<div align="center">password: </div>
</label>
<div align="center">
<input type="password" name="password" id="password" />
<br/>
<input type="submit" name="Submit" value="Submit" id="Submit" />
</div>
<div align="center">Forgotten your password? <a href="';
echo $server;
echo '?page=forgot">Click here</a></div>
</form>
</body>
</html>';
}
}
}
else {
$id;
$adminnav = '<a href="?id=home">home</a> | <a href="?id=addcontent">add content</a> | <a href="?id=editcontent">edit content</a> | <a href="?id=delcontent">delete content</a> | <a href="?id=addcatagory">add catagory</a> | <a href="?id=editcatagory">edit catagory</a> | <a href="?id=delcatagory">delete catagory</a> | <a href="?id=logout">log out</a><br/>';
if (!isset($id)) {
echo $header;
echo $adminnav;
echo 'you are already logged in, to logout <a href="?id=logout">Click Here</a><br/>';
echo $footer;
}
else {
switch ($id) {
case logout:
setcookie ('account', $user, time()-3600);
header ('location: secure.php');
case home:
echo $header;
echo $adminnav;
echo 'welcome to the home page you can manage your website content here';
echo $footer;
break;
case addcontent:
echo $header;
echo $adminnav;
echo 'If you would like to add more content to your website please use the following forms';
echo $footer;
break;
case editcontent:
echo $header;
echo $adminnav;
echo 'If you would like to change and edit the content on your website use the following forms';
break;
case delcontent:
echo $header;
echo $adminnav;
echo 'To remove content from your website select the catagory you would like to remove it from, then click the delete button beside it.';
echo $footer;
break;
case addcatagory:
echo $header;
echo $adminnav;
echo 'If you would like to add a new catagory to your website please enter its name below and select submit';
echo $footer;
break;
case editcatagory:
echo $header;
echo $adminnav;
echo 'To change a catagory, select and edit the catagory of your choice';
echo $footer;
break;
case delcatagory:
echo $header;
echo $adminnav;
echo 'If you want to delete a catagory select the one you would like to remove then hit delete.';
echo $footer;
break;
default:
echo $header;
echo $adminnav;
echo 'The page you are looking for cannot be found please use the above links.';
echo $footer;
}
}
}
}
?>