What's wrong? It can't define what stands in this title, and the textbox's name sent HAS the name username
PHP Code:<?php
include('config.php');
// connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);
mysql_select_db($dbname) or die('Cannot select database');
if ( isset( $_COOKIE['SundhedU'] ) && isset( $_COOKIE['SundhedP'] ) )
{
header( "Location: main.php" );
}
else
{
if($_POST['username'] {
//did they supply a password and username
$username=$_POST['username'];
$password=$_POST['password'];
if ($password==NULL) {
echo "<META HTTP-EQUIV='REFRESH' CONTENT='0;URL=index.php'>
";
}
else
{
$query = mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error());
$data = mysql_fetch_array($query);
if($data['password'] != md5($password))
{
echo "<META HTTP-EQUIV='REFRESH' CONTENT='0;URL=index.php'>";
}
else
{
if (isset($_POST['husklogin']))
{
setcookie('SundhedU', $username, time() + 3600 * 24 * 365);
setcookie('SundhedP', md5($password), time() + 3600 * 24 * 365);
$query = mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error());
$row = mysql_fetch_array($query);
$_SESSION["s_username"] = $row['username'];
header("Location: index.php");
}else{
$query = mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error());
$row = mysql_fetch_array($query);
$_SESSION["s_username"] = $row['username'];
header("Location: index.php");
}
}
}
}
}
?>




Reply With Quote