i have written a login script (well, copied it from a book) and it just gives me a blank page
the result is
http://cgi.lochviewwest.plus.com/login.php
this is the code:
<?php
if (isset($_POST['submit'])) {
require_once ('mysql_connect.php');
function escape_data ($data) {
global $dbc;
if (ini_get('magic_quotes_gpc')) {
$data = stripslashes($data);
}
return mysql_real_escape_string($data, $dbc);
}
$message = NULL;
if (empty($_POST['username'])) {
$u = FALSE;
$message .= '<p>You forgot to enter you username']);
}
if (empty($_POST['password'])) {
$p = FALSE;
$message .= '<p>You forgot to enter your password!</p>';
} else {
$p escape_data($_POST['password']);
}
if ($u && $p) {
$query = 'SELECT user_id, first_name FROM users WHERE username='$u' AND password=PASSWORD('$p')";
$result = @mysql_query ($query);
$row = mysql_fetch_array ($result, MYSQL_NUMB);
if ($row) {
setcookie ('first_name', $row[1]);
setcookie ('user_id', $row[0]);
header ("location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "loggedin.php");
exit()
} else {
$message = '<P>Tthe username and password entered do not match thoe in file.</P>';
}
mysql_close() ;
} else {
$message .= '<P>Please try again.<P>';
}
}
?>
<html><body>
<?php
of isset($message)) {
echo '<font color="red">', $messgae, '</font>';
}
?>
<form action=<?php echo $_SERVER['PHP_SELF'];?>" method="post">
<fieldset><legend>Enter your login name and password:</legend>
<p><b>User Name:</b> <input type="password" name="password" size="20" maxlength="20" /></p>
<div align-"center"><input type="submit" name="submit" value="login" /></div>
</form>
</body></html>
please help, the mysql_connect.phhp consists of:
<?php
define ('DB_USER', 'my login name');
define ('DB_PASSWORD', 'my password');
define ('DB_HOST', 'server');
define ('DB_NAME', 'database name');
$dbc = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die ('could not connect to mysql: ' . mysql_error() );
mysql_select_db (DB_NAME) or die ('could not select the database: ' . mysql_error() );
?>
this script works on it's own (well, produces a blank page) and i have the correct names and password, i'm just not telling anyone here them.
can someone please help me
http://www.larinar.tk
AMD athlon thoroughbred 2200, 512Mb ram, 40Gb HD, ati saphire radeon 9600 atlantis w/128mb ddr ram, good creative-labs soundcard, cd-rw + dvd drives.