hey guys,
i understand you must always start a session (for cookies) before the HTML tags – BUT its throwing out my whole page. ie – my form was nicely centered now its skewed to the left ?
please advise how to rectify this
here is the opening code
[code=php]
<?php
//check for required fields from the form
if (!isset($_POST[username]) || !isset($_POST[password])) {
header(“Location: login.html”);
exit;
}
//connect to server and select database
DEFINE (DB_USER, “”);
DEFINE (DB_PASSWORD, “”);
DEFINE (DB_HOST, “localhost”);
DEFINE (DB_TEST, “test”);
$conn = mysql_connect (‘localhost’, ”,”) or die (‘could not connect to MYSQL because: ‘ . mysql_error());
mysql_select_db (blueprintdb) or die (‘could not select the DB because: ‘ . mysql_error());
//create and issue the query
$sql = “select first_name, last_name from users where username = ‘$_POST[username]’ AND password = ‘$_POST[password]'”;
$result = mysql_query($sql,$conn) or die(“User Query Error “.mysql_error());
//get the number of rows in the result set; should be 1 if a match
if (mysql_num_rows($result) == 1) {
//if authorized, get the values of f_name l_name
$first_name = mysql_result($result, 0, ‘first_name’);
$last_name = mysql_result($result, 0, ‘last_name’);
//set authorization cookie
setcookie(“auth”, “1”, 0, “/”, “questionnaireproject.com”, 0);
print “Cookie status: authorised-“.$_COOKIE[auth];
//prepare message for printing, and user menu
$msg = “Welcome to Dynamic Homes $first_name!”;
$msg .= “Authorised Users Menu:”;
$msg .= “<ul><li><a href=”index.html”>Return to Home Page</a></ul>”;
} else
{
//redirect back to login form if not authorised
header(“Location: wrong.html”);
//print “Wrong user name or password. Please try login again</a>”;
exit;
}
?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>