Ok, so, You say that any spaces within html content will cause the header() function to fail. But it doesnt matter where the header() function is placed within a php tag. as long as the php TAG is at the very top of the page before anything else. ok. So here is the next problem. I have a method called verify. which checks the users name and password. if the user name and password is either right or wrong it redirects the browser some where else.
When the user press submits, the form sends the user to a page called check.php. at the very top of that page before anything else, the verify() method is called. the method is within a class called frontend. the class called frontend is within a document called application.php. the document has no html in it. all it has is php script. at the very top of the page it starts like this
<?php
frontend
{
public function verify(){
script..............
header(location: document.php);
}
}
?>
from within the method, the header() function is called. Yet i still get the error. the browser says that the error is coming from the document application.php which is the document that holds the class frontend which holds the method verify. I have no echos within the tag either.
Would a sprintf be considered a output ??
would a die() Be considered output
below is all the code written before the header is sent on the application page
<?php
class frontend
{
public $table = "users";
public $columns = "firstName, lastName, loginName, passWord, userlevel";
////////////////////////////////////////////////////////////////////////////////////
public function verify($login, $password){
session_start();
if ($login !="" and $password != ""){
require('connections/ok.php');
mysql_select_db($database_ok,$ok);
$query = sprintf("SELECT firstName,lastName, loginName, passWord, USERID
FROM users
WHERE loginName = '%s'",mysql_real_escape_string($login));
$results = mysql_query($query,$ok);
$check = mysql_fetch_assoc($results);
if (strcasecmp($login,$check['loginName']) == 0
and strcmp($password,$check['passWord'])== 0){
$_SESSION['user'] = array('firstname'=>$check['firstName'],
'lastName'=>$check['lastName'],
'loginName'=>$check['loginName'],
'password'=>$check['passWord'],
'userID'=>$check['USERID']);
$_SESSION['error'] = "";
header('location: http://localhost/index.php');
}
}
else {
$_SESSION['error'] = 'Invalid User Name or Password';
header('location: http://localhost/index.php');
}
}