Hi !
I am tryinf to run the sample from the book linux.mysql,apache..and i keep geetign these errors..
errors :
Warning: Cannot modify header information - headers already sent by (output started at /home/kaiser/public_html/PHP/REGISTER/useraccess.php:8) in /home/kaiser/public_html/PHP/REGISTER/useraccess.php on line 31
Warning: Cannot modify header information - headers already sent by (output started at /home/kaiser/public_html/PHP/REGISTER/useraccess.php:8) in /home/kaiser/public_html/PHP/REGISTER/useraccess.php on line 32
Thanks in advance
and here is the actual code itself:
<?
// Filename : useraccess.php
// This file check for user login information
// Also, it check the user select theme for the PAGE
function checkAccess() {
echo " <br>inside checkAccess<br> ";
// First chekc for a POST
$email =$_POST['email'];
$password = $_POST['password'];
$remember = $_POST['remember'];
echo " Email $email <br>";
echo " pwd $password <br>";
//If no POST check fro cookie
if($email == NULL) {
echo " error inside if <br>";
$email = $_COOKIE['dummyemail'];
$password =$_COOKIE['dummypassword'];
echo " Email $email <br>";
echo " pwd $password <br>";
}
elseif (!$remember) {
//If there was a POST , save the cookie
// This will wipe out any lojn-term
// cookies by this same time.
echo " error inside elseif <br>";
setcookie('dummyemail',$email);
setcookie('dummypassword',$password);
echo " Email $email <br>";
//echo " pwd $password <br>";
}
$okay = false;
if ($email && $password) {
echo " inside if by mysql connect<br>";
mysql_connect("localhost","user","pass") or die ("Coudln't connect to server");
$sql ="select loginID,password,themeID FROM phpbase.login WHERE email='$email'";
$result = mysql_query($sql) or die("Coudln't query");
if($result) {
if(mysql_num_rows($result) > 0) {
$row = mysql_fetch_array($result);
$pass = $row['password'];
$userid = $row['loginID'];
$theme = $row['themeID'];
echo "<br>row : $row <br>";
echo "<br>pass : $pass <br>";
echo "<br>userid : $userid<br>";
echo "<br>theme : $theme <br>";
$passcrypt = crypt($password,substr($pass,0,12));
if($pass ==$passcrypt) {
$okay =true;
}
}
}
mysql_close();
}
if(!$okay) {
header("location: loginfailed.html");
}
if($remember) {
//remeber until may17 2033
// lon term cookie
setcookie('dummyemail',$email,2000000000);
setcookie('dummypassword',$password,2000000000);
}
return $theme;
echo "<br> <br>";
echo "<br> End of checkAccess<br>";
}//End_of_checkAccess()
function signup($email, $password, $themeID) {
echo " <br>inside signup<br> ";
mysql_connect("localhost","user","pass") or die ("Couldn't Connect to server");
$passcrypt = crypt($password);
echo " <br>INSIDE signup<br> ";
echo "pass : $passcrypt ";
$now = date("Y-m-d");
echo "now : $now<br> ";
echo "email :$email<br> ";
echo "password : $password<br> ";
echo "themeID : $themeID<br> ";
$insert_sql = " INSERT INTO phpbase.login(email, password, lastaccess, signup,themeID)
VALUES ('$email','$passcrypt','$now', '$now','$themeID')";
echo "<br> insert_sql : $insert_sql<br> ";
$result = mysql_query($insert_sql) or die ("Couldn't Insert into Table");
echo " <br>Exiting signup<br> ";
mysql_close();
return $result;
} // End_Of_signup
class ThemeInfo {
var $bgcolor;
}
function getTheme ($themeID) {
mysql_connect("localhost","user","pass") or die ("Couldn't connect to server");
$newtheme = new ThemeInfo;
$newtheme->bgcolor = "FFFFFF"; //white bg
$sql = "select backgroundcolor from phpbase.usertheme where themeID= '$themeID'";
$result = mysql_query($sql);
if ($result) {
if(mysql_num_rows($result) > 0 ) {
$row =mysql_fetch_array($result);
$newtheme->bgcolor = $row['backgroundcolor'];
}
}
mysql_close();
return $newtheme ;
} //End_Of_getTheme
function GetThemeNames() {
mysql_connect("localhost","user","pass") or die ("Couldn't connect to server");
$result = mysql_query("select * from phpbase.usertheme");
if($result) {
if(mysql_num_rows($result)> 0 ) {
while ($row = mysql_fetch_array($result)) {
$name = $row["name"];
$num = $row["themeID"];
$themeByNum[$num] = $name;
}
}
mysql_free_result($result);
}
mysql_close();
return $themeByNum;
} // EndOfGetThemeNames
function GeneratePassword() {
$wordList = array("apple","banana","bold","cook","catalog","animal","jump",
"tophat","wipe","wane","vanish","making","england","video","heavy","upside","keep"
,"merry","icecream","funny","flag","flower");
$firstword = $wordlist[rand(0,count($wordList) -1)];
$secondword = $wordlist[rand(0,count($wordList) -1)];
$number =rand(10,99);
$newpass = $firstword.$number.$secondword;
return $newpass;
}
?>
I am tryinf to run the sample from the book linux.mysql,apache..and i keep geetign these errors..
errors :
Warning: Cannot modify header information - headers already sent by (output started at /home/kaiser/public_html/PHP/REGISTER/useraccess.php:8) in /home/kaiser/public_html/PHP/REGISTER/useraccess.php on line 31
Warning: Cannot modify header information - headers already sent by (output started at /home/kaiser/public_html/PHP/REGISTER/useraccess.php:8) in /home/kaiser/public_html/PHP/REGISTER/useraccess.php on line 32
Thanks in advance
and here is the actual code itself:
<?
// Filename : useraccess.php
// This file check for user login information
// Also, it check the user select theme for the PAGE
function checkAccess() {
echo " <br>inside checkAccess<br> ";
// First chekc for a POST
$email =$_POST['email'];
$password = $_POST['password'];
$remember = $_POST['remember'];
echo " Email $email <br>";
echo " pwd $password <br>";
//If no POST check fro cookie
if($email == NULL) {
echo " error inside if <br>";
$email = $_COOKIE['dummyemail'];
$password =$_COOKIE['dummypassword'];
echo " Email $email <br>";
echo " pwd $password <br>";
}
elseif (!$remember) {
//If there was a POST , save the cookie
// This will wipe out any lojn-term
// cookies by this same time.
echo " error inside elseif <br>";
setcookie('dummyemail',$email);
setcookie('dummypassword',$password);
echo " Email $email <br>";
//echo " pwd $password <br>";
}
$okay = false;
if ($email && $password) {
echo " inside if by mysql connect<br>";
mysql_connect("localhost","user","pass") or die ("Coudln't connect to server");
$sql ="select loginID,password,themeID FROM phpbase.login WHERE email='$email'";
$result = mysql_query($sql) or die("Coudln't query");
if($result) {
if(mysql_num_rows($result) > 0) {
$row = mysql_fetch_array($result);
$pass = $row['password'];
$userid = $row['loginID'];
$theme = $row['themeID'];
echo "<br>row : $row <br>";
echo "<br>pass : $pass <br>";
echo "<br>userid : $userid<br>";
echo "<br>theme : $theme <br>";
$passcrypt = crypt($password,substr($pass,0,12));
if($pass ==$passcrypt) {
$okay =true;
}
}
}
mysql_close();
}
if(!$okay) {
header("location: loginfailed.html");
}
if($remember) {
//remeber until may17 2033
// lon term cookie
setcookie('dummyemail',$email,2000000000);
setcookie('dummypassword',$password,2000000000);
}
return $theme;
echo "<br> <br>";
echo "<br> End of checkAccess<br>";
}//End_of_checkAccess()
function signup($email, $password, $themeID) {
echo " <br>inside signup<br> ";
mysql_connect("localhost","user","pass") or die ("Couldn't Connect to server");
$passcrypt = crypt($password);
echo " <br>INSIDE signup<br> ";
echo "pass : $passcrypt ";
$now = date("Y-m-d");
echo "now : $now<br> ";
echo "email :$email<br> ";
echo "password : $password<br> ";
echo "themeID : $themeID<br> ";
$insert_sql = " INSERT INTO phpbase.login(email, password, lastaccess, signup,themeID)
VALUES ('$email','$passcrypt','$now', '$now','$themeID')";
echo "<br> insert_sql : $insert_sql<br> ";
$result = mysql_query($insert_sql) or die ("Couldn't Insert into Table");
echo " <br>Exiting signup<br> ";
mysql_close();
return $result;
} // End_Of_signup
class ThemeInfo {
var $bgcolor;
}
function getTheme ($themeID) {
mysql_connect("localhost","user","pass") or die ("Couldn't connect to server");
$newtheme = new ThemeInfo;
$newtheme->bgcolor = "FFFFFF"; //white bg
$sql = "select backgroundcolor from phpbase.usertheme where themeID= '$themeID'";
$result = mysql_query($sql);
if ($result) {
if(mysql_num_rows($result) > 0 ) {
$row =mysql_fetch_array($result);
$newtheme->bgcolor = $row['backgroundcolor'];
}
}
mysql_close();
return $newtheme ;
} //End_Of_getTheme
function GetThemeNames() {
mysql_connect("localhost","user","pass") or die ("Couldn't connect to server");
$result = mysql_query("select * from phpbase.usertheme");
if($result) {
if(mysql_num_rows($result)> 0 ) {
while ($row = mysql_fetch_array($result)) {
$name = $row["name"];
$num = $row["themeID"];
$themeByNum[$num] = $name;
}
}
mysql_free_result($result);
}
mysql_close();
return $themeByNum;
} // EndOfGetThemeNames
function GeneratePassword() {
$wordList = array("apple","banana","bold","cook","catalog","animal","jump",
"tophat","wipe","wane","vanish","making","england","video","heavy","upside","keep"
,"merry","icecream","funny","flag","flower");
$firstword = $wordlist[rand(0,count($wordList) -1)];
$secondword = $wordlist[rand(0,count($wordList) -1)];
$number =rand(10,99);
$newpass = $firstword.$number.$secondword;
return $newpass;
}
?>