I am very proud of myself today for figuring out a problem. However i just created another one that kinda stumped me.
I was have a headers already sent problem so i started using ob_start and ob_end_clean. Let me show you the code then i'll tell you the problem
login.php
UW PICO(tm) 4.2 File: login.php Modified
<?PHP
include('functions.inc');
include('header.php');
?>
<?php
ob_start();
userlogin($uname,$pass);
ob_end_clean();
?>
function.inc function
function userlogin() {
echo $pass;
echo "</p>";
echo $uname;
echo "</p>";
$uname = $_POST['uname'];
$pass = $_POST['pass'];
$con = mysql_connect("localhost", "", "") or die(mysql_error());
$db = mysql_select_db("pinehead", $con) or die(mysql_error());
$sql = "SELECT * FROM users where uname='$uname' and pass='$pass'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
if ($row["uname"] == $uname && $row["pass"] ==
$pass) {
setcookie ("user", $uname, time()+604800);
echo "you are now logged in";
} else {
echo "Incorrect login";
}
}
It is loggin me in and setting the cookie, however it is not displaying "You are now logged in" or echoing the username and pass like it is suppose to. I know it is becuase of the ob functions becuase it echoed everything correctly before when i got the header functions error.
Thank you for your help
Anthony