Hi guys,
I just finished my first little newsscript.
Now I'm trying to make a login for myself only.
So I made the database and the following login script
<?php
include("db.php");
session_start();
if($_SERVER["REQUEST_METHOD"] == "POST")
{
// username and password sent from Form
$username=mysql_real_escape_string($_POST['username']);
$password=mysql_real_escape_string($_POST['password']);
$password=md5($password); // Encrypted Password
$sql="SELECT id FROM admin WHERE username='$username' and passcode='$password'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
// If result matched $username and $password, table row must be 1 row
if($count==1)
{
header("location: testing.php");
}
else
{
$error="Wrong!";
}
}
?>
<h1>Restricted Area</h1>
<p>Administrator Only.<br/></p>
<form action="login.php" method="post">
<table border="0" cellpadding="0" cellspacing="2">
<tr>
<td>
Administrator:
</td>
</tr>
<tr>
<td><input type="text" name="username"/><br /></td>
</tr>
<tr>
<td>
Password:
</td>
</tr>
<tr>
<td><input type="password" name="password"/><br/></td>
</tr>
<tr>
<td><input type="submit" value="Login"></td>
</tr>
</table>
</form>
</body>
</html>
This script works, it shows the testing.php page, but the login form
stays on top of it. That's not what I wanted, I would like a login form that redirects my to testing.php
How do I have to do this?
db.php
$mysql_hostname = "";
$mysql_user = "";
$mysql_password = "";
$mysql_database = "";
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password)
or die("not connected");
mysql_select_db($mysql_database, $bd) or die("not connected");