Hi all.
Am working on a simple login script for a site I am developing, and I want to have cookies working, with a md5'd username and pass in each, but I can't for the life of me get them to work properly, ending up with a cannot modify header output.
Heres my code..
<?php
if(isset($_POST['username'])) {
$passhash = (md5($_POST[password]));
$userhash = (md5($_POST[username]));
include("db.php");
$kick = mysql_connect($server, $db_user, $db_pass)
or die ("".mysql_error());
mysql_select_db($database)
or die ("".mysql_error());
$match = "select id from axis_login where username = '".$_POST['username']."' and password = '$passhash';";
$qry = mysql_query($match)
or die ("Could not match data because ".mysql_error());
$num_rows = mysql_num_rows($qry);
if ($num_rows <= 0) {
echo "Died";
exit;
} else {
setcookie("axis_loggedin", "TRUE", time()+(3600 * 24));
setcookie("axis_username", "$userhash");
setcookie("axis_password", "$passhash");
echo "logged in";
}
}
?>
And when this executes, I get the good old cannot modify headers (running on a local copy of apache etc in xampp)
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\lgnproc.php:1) in C:\xampp\htdocs\lgnproc.php on line 18
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\lgnproc.php:1) in C:\xampp\htdocs\lgnproc.php on line 19
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\lgnproc.php:1) in C:\xampp\htdocs\lgnproc.php on line 20
logged in
Before you ask, I have checked for whitespace outside either of the PHP brackets and there is absolutly none there.... I can't see where I am going wrong.
Any chance of a helping hand? Would be much appriciated
Thanks all
Jordan