Hi!
I am new to php. I created a login (php5.2.5) page using
dreamweaver cs3 with mysql database. I have added
the login user server behaviour. When I preview, the login
page opens, i enter the username and password, but
the username and password is not validated and page not
redirected, remains as it is. I get the following error
in the localhost.error.log:
PHP Warning: Cannot modify header information - headers
already sent by (output started at C:\\Program
Files\\Apache Software
Foundation\\Apache2.2\\htdocs\\PHPCLI\\main.php:1) in C:\\Program
Files\\Apache Software
Foundation\\Apache2.2\\htdocs\\PHPCLI\\main.php on line 68,
referer:
http://localhost/main.php
The page worked fine before adding login server behaviour.
Here is the code from main.php(created thru dw cs3). mysql
database created thru phpmyadmin.
<?php virtual('/Connections/js.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType,
$theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue)
: $theValue;
$theValue = function_exists("mysql_real_escape_string") ?
mysql_real_escape_string($theValue) :
mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" :
"NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) .
"'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" :
"NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue :
$theNotDefinedValue;
break;
}
return $theValue;
}
}
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType,
$theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue)
: $theValue;
$theValue = function_exists("mysql_real_escape_string") ?
mysql_real_escape_string($theValue) :
mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" :
"NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) .
"'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" :
"NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue :
$theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_js, $js);
$query_jsrecord = "SELECT * FROM matrimony";
$jsrecord = mysql_query($query_jsrecord, $js) or
die(mysql_error());
$row_jsrecord = mysql_fetch_assoc($jsrecord);
$totalRows_jsrecord = mysql_num_rows($jsrecord);
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['profileid'])) {
$loginUsername=$_POST['profileid'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "/jsdirectory.php";
$MM_redirectLoginFailed = "/errorlogin.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_js, $js);
$LoginRS__query=sprintf("SELECT profileid, password FROM
matrimony WHERE profileid=%s AND
password=%s",
GetSQLValueString($loginUsername, "text"),
GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $js) or
die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<!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>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
background-color: #FFFFFF;
}
-->
</style></head>
<body>
<div id="main">
<div align="center">
<p> </p>
<form action="<?php echo $loginFormAction; ?>"
method="POST" name="jsloginform" id="jsloginform">
<table width="100" border="1">
<tr>
<td><label for="profileid">profile
id</label>
<input type="text" name="profileid" id="profileid"
/></td>
</tr>
<tr>
<td><label for="password">password</label>
<input type="password" name="password" id="password"
/></td>
</tr>
<tr>
<td><label for="submit"></label>
<input type="submit" name="submit" id="submit"
value="Submit" /></td>
</tr>
</table>
</form>
<p> </p>
</div>
</div>
</body>
</html>
<?php
mysql_free_result($jsrecord);
?>
Kindly help...