I'm trying validate a user and then send him/her to another page if they are valid. Plus check that the $login is there by calling the session on that page to make sure that the person did login.
The validation works fine but I get this error:
Warning: Cannot add header information - headers already sent by (output started at /*//.php:3) in //*//***.php on line 39
plus I have some java script on the page and the SID gets written to it and causes an error too.
this is line 1 ---> <?session_start();?>
<?
if($action)
{
if ((!$username) || (!$password))
{
$msg = "Must enter Username or Password";
}
$db_name = "*****";
$table_name = "*******";
$connection = mysql_connect("***", "*", "*******") or die("Couldn't connect.");
$db = mysql_select_db($db_name, $connection) or die("Couldn't select database.");
$sql = "select username and password from $table_name where username ='$username' and password ='$password'";
$result = mysql_query($sql,$connection) or die("Couldn't execute query 1.");
$num = mysql_num_rows($result);
if ($num == 0)
{
$msg = "Bad Login try again.";
}
if ($num !=0)
{
$login = $username;
session_register("login");
header("location: /*/***.php");
exit;
}
}
?>
Any help would be great. Thanks