And here is the code for the main page and the top iframe:
top.php:
Code: Select all
<?php
session_start();
$hostname="localhost"; //we define a variable
$username="root"; //we define a username
$password=""; //we define a password
$dbname="main"; // we define a db name
$cont=mysql_connect($hostname,$username,$password);
if($cont !=false){
if(!mysql_select_db($dbname,$cont)) {
echo "can not connect to database";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<?php
if(isset($_SESSION['loggedin']))
{
echo"You are already logged in!<a href=\"main.php?logout=1\" target=\"main\">Log out!</a>";
}
else {
echo "UserName : Password:</keimenoC>";
echo "<form action=\"main.php\" method=\"post\" target =\"main.php\"><formaA>";
echo "<input type=\"text\" size=\"12\" name=\"username\" >";
echo "<input type=\"password\" size=\"12\" name=\"password\"></formaA>";
echo "<formaAButton><input type=\"image\" src=\"login.bmp\" VALUE=\"Login\" /></formaAButton>";
echo "</form>";
// echo "<form type='main.php' method='POST'>
// Username: <br>
// <input type='text' name='username'><br>
// Password: <br>
// <input type='password' name='password'><br>
// <input type='submit' name='submit' value='Login'>
// </form>"; // That set up the form to enter your password and username to login.
}
?>
</body>
</html>
Code: Select all
<?php
session_start();
//session_destroy();
if($_GET["logout"] == 1){unset($_SESSION['loggedin']);}
$hostname="localhost"; //we define a variable
$username="root"; //we define a username
$password=""; //we define a password
$dbname="main"; // we define a db name
$cont=mysql_connect($hostname,$username,$password);
if($cont !=false){
if(!mysql_select_db($dbname,$cont)) {
echo "can not connect to database";
}
}
if($_POST["username"] && $_POST["password"])
{
$name = mysql_real_escape_string($_POST['username']); // The function mysql_real_escape_string() stops hackers!
$pass = mysql_real_escape_string($_POST['password']); // We won't use MD5 encryption here because it is the simple tutorial, if you don't know what MD5 is, dont worry!
$mysql = mysql_query("SELECT * FROM users WHERE username = '{$name}' AND password = '{$pass}'"); // This code uses MySQL to get all of the users in the database with that username and password.
while($rowLogin = mysql_fetch_array($mysql)){
$_SESSION['loggedin'] = "YES";
$_SESSION['name'] = $name; // Make it so the username can be called by $_SESSION['name']
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>TEST! </title>
<link rel="stylesheet" type="text/css" media="screen" href="styles.css" />
</head>
<body>
<iframe id="header" frameborder = "0" height = "100" width = "1350" src="top.php" </iframe>
<iframe id="draggableNodes" frameborder = "0" height = "900" width = "250" src="draggableNodesFrame.php"></iframe>
<iframe name="middle" id="middle" frameborder = "0" height = "900" width = "800" src="middle.php"></iframe>
<iframe id="dropTargets" frameborder = "0" height = "900" width = "250" src="dropTargetFrame.php"></iframe>
<iframe id="bottom" frameborder = "0" height = "100" width = "1350" src="bottom.html"></iframe>
</body>
</html>