Code: Select all
<!DOCTYPE html>
<head>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
include_once('connect.php');
session_start();
if(isset($_POST['submit'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$username = strip_tags($username);
$password = strip_tags($password);
$password = md5($password);
$query = "SELECT username,password from players where username='$username' and '$password'";
$result = mysql_query($query) or die(mysql_error());
$result2 = mysql_fetch_array($result);
if($result2) {
$_SESSION['username'] = $username;
echo "You have logged in successfully!<br><a href='index.php'>Login</a>";
}
if($username != $result2['username'] || $password != $result2['password']) {
echo "Username or password was incorrect. <br><a href='home.php'>Go Back</a>";
}
}
?>
</body>
</html>Code: Select all
<div id="login">
<form method="post" action="authenticate.php">
Username:<input type="text" name="username" size="21" /><br/>
Password:<input type="password" name="password" size="32" />
<input type="submit" value="Login" /><br/>
</form>
<a href="register.php">Register</a>
</div>