I have a warning message:
Warning: Cannot modify header information - headers already sent by (output started at LG.php:10) in LG.php on line 45
Basically I have a problem with a log in sequence. If a user goes on the site, and does not enter any login data, but hits submit, he gets directed to Google. If the user then returns, but enters data and tries to log in pressing submit, then the warning above appears??
The initial form is an HTML form. The contents get posted to the form that checks if valid entry.
The code for the 1st form is:
<SELECT NAME=Location SIZE=7 style="font-weight: 700">
<OPTION>ITV Tyne Tees TV
<OPTION>ITV Westcountry TV
<OPTION>ITV Yorkshire TV
</SELECT></span></p>
<p><b><font face="Arial" size="4" color="#0000FF"><u>Please enter your name</u></font></b></p>
<p>
<font size="3" face="Arial">
<INPUT NAME="UserName" size="28" style="font-weight: 700" ></font></p>
<p><b><font face="Arial" size="4" color="#0000FF"><u>Please enter your </u></font></b>
<u><b><font face="Arial" size="4" color="#0000FF">user ID</font></b></u></p>
<p>
<font size="3" face="Arial">
<INPUT NAME="UserID" size="28" style="font-weight: 700" ></font></p>
<p><input type="submit" name="submit" value="Submit!"></p>
<p> </p>
<p> </p>
</form>
</body>
</html>
The data then gets posted to this PHP page/form
<?php
session_start();
$Location = $_POST['Location'] ;
$UserName = $_POST['UserName'] ;
$UID = $_POST['UserID'] ;
$db = mysql_connect("xxx", "xxx_xxx", "xxx");
mysql_select_db("xxx_xxx",$db) or die("Select DB Error: ".mysql_error());
$sql = "select * from Validnames where UserName = '$UserName' && UserID = '$UID' && Location = '$Location'";
if ($qry = mysql_query($sql)) {
$numrows = mysql_num_rows($qry);
}
if ($numrows > 0) {
// Dont forget to register the session if it isnt already
$_SESSION['UserName'] = $UserName;
header('location: newmenu.php');
exit();
} else {
// Send them on a jolly trip to google!
//header("Location: //exit();
$url = " echo '<script type="text/javascript">top.location.href = "' . $url . '";</script>';
}
?>
Any suggestions of where/why its going wrong appreciated.
Warning: Cannot modify header information - headers already sent by (output started at LG.php:10) in LG.php on line 45
Basically I have a problem with a log in sequence. If a user goes on the site, and does not enter any login data, but hits submit, he gets directed to Google. If the user then returns, but enters data and tries to log in pressing submit, then the warning above appears??
The initial form is an HTML form. The contents get posted to the form that checks if valid entry.
The code for the 1st form is:
<SELECT NAME=Location SIZE=7 style="font-weight: 700">
<OPTION>ITV Tyne Tees TV
<OPTION>ITV Westcountry TV
<OPTION>ITV Yorkshire TV
</SELECT></span></p>
<p><b><font face="Arial" size="4" color="#0000FF"><u>Please enter your name</u></font></b></p>
<p>
<font size="3" face="Arial">
<INPUT NAME="UserName" size="28" style="font-weight: 700" ></font></p>
<p><b><font face="Arial" size="4" color="#0000FF"><u>Please enter your </u></font></b>
<u><b><font face="Arial" size="4" color="#0000FF">user ID</font></b></u></p>
<p>
<font size="3" face="Arial">
<INPUT NAME="UserID" size="28" style="font-weight: 700" ></font></p>
<p><input type="submit" name="submit" value="Submit!"></p>
<p> </p>
<p> </p>
</form>
</body>
</html>
The data then gets posted to this PHP page/form
<?php
session_start();
$Location = $_POST['Location'] ;
$UserName = $_POST['UserName'] ;
$UID = $_POST['UserID'] ;
$db = mysql_connect("xxx", "xxx_xxx", "xxx");
mysql_select_db("xxx_xxx",$db) or die("Select DB Error: ".mysql_error());
$sql = "select * from Validnames where UserName = '$UserName' && UserID = '$UID' && Location = '$Location'";
if ($qry = mysql_query($sql)) {
$numrows = mysql_num_rows($qry);
}
if ($numrows > 0) {
// Dont forget to register the session if it isnt already
$_SESSION['UserName'] = $UserName;
header('location: newmenu.php');
exit();
} else {
// Send them on a jolly trip to google!
//header("Location: //exit();
$url = " echo '<script type="text/javascript">top.location.href = "' . $url . '";</script>';
}
?>
Any suggestions of where/why its going wrong appreciated.