Redirect header is getting error
Posted: Fri Feb 25, 2011 3:53 am
Hi my name is nigil,
This is my first php help question ever to any website as I am a newbie. I have a script which searches a value called serial number and finds its other fields like name and warranty. This all works fine, the thing is when there is an serial been put which is not in the database it should redirect to the missing.html This part is i am getting error message given below:
Warning: Cannot modify header information - headers already sent by (output started at /home/bjventur/public_html/it@school/welcome.php:5) in /home/bjventur/public_html/it@school/welcome.php on line 39
Please Help my My full php code is given below:
<HTML><HEAD>
<TITLE>Details</TITLE>
<style type="text/css">
BODY { COLOR: #0000FF; FONT: 12px verdana, arial, sans-serif; font-weight: normal }
</style>
<link rel="stylesheet" type="text/css" href="style.css" />
</HEAD> <BODY bgColor="#FFFFFF">
<p> </p>
<p> </p>
<p align="center"><br>
<br>
<font color="#333333">Welcome Dear Mr. <?php echo $_POST["txtname"]; ?>, Please
find below the details you have inquired;</font></p>
<p align="center"> </p><br><br><br><br><br><br>
<p align="center"><strong><br>
<?php
$txtserial = $_POST['txtserial'];
// Make a MySQL Connection
mysql_connect("localhost", "bjventur_basha", "nagma@rajani11") or die(mysql_error());
mysql_select_db("bjventur_test") or die(mysql_error());
// Get a specific result from the "dikon" table
$result = mysql_query("SELECT * FROM bjventur_dikon
WHERE serial='$txtserial'") or die(mysql_error());
// get the first (and hopefully only) entry from the result
$row = mysql_fetch_array( $result );
if ($row == 0)
{
header('Location: http://www.website.com/missing.html');
}
else
{
}
// Print out the contents of each row into a table
echo " Serial Number: " .$row['serial'];
echo "<br />";
echo "<br />";
echo " Customer Name: ".$row['name'];
echo "<br />";
echo "<br />";
echo " Warranty upto: ".$row['warranty'];
?>
</strong></p>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<p align="center"><font color="#333333">For Service Please call at <strong>008-8803-333</strong></font></p>
<p align="center"><font color="#333333"><em>Thank you for visiting!</em></font></p>
<p> </p>
<p> </p>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center">
<p><font color="#666666" size="2" face="Arial, Helvetica, sans-serif">
</font></p>
<p><font color="#FFFFFF" size="1" face="Arial, Helvetica, sans-serif">Powered
by</font><font color="#666666" size="1" face="Arial, Helvetica, sans-serif">
<a href="http://www.website.com" target="_blank" style="text-decoration:none"><font color="#FFFFFF">nigil</font></a></font></p>
</div></td>
</tr>
</table>
<p> </p>
</BODY></HTML>
This is my first php help question ever to any website as I am a newbie. I have a script which searches a value called serial number and finds its other fields like name and warranty. This all works fine, the thing is when there is an serial been put which is not in the database it should redirect to the missing.html This part is i am getting error message given below:
Warning: Cannot modify header information - headers already sent by (output started at /home/bjventur/public_html/it@school/welcome.php:5) in /home/bjventur/public_html/it@school/welcome.php on line 39
Please Help my My full php code is given below:
<HTML><HEAD>
<TITLE>Details</TITLE>
<style type="text/css">
BODY { COLOR: #0000FF; FONT: 12px verdana, arial, sans-serif; font-weight: normal }
</style>
<link rel="stylesheet" type="text/css" href="style.css" />
</HEAD> <BODY bgColor="#FFFFFF">
<p> </p>
<p> </p>
<p align="center"><br>
<br>
<font color="#333333">Welcome Dear Mr. <?php echo $_POST["txtname"]; ?>, Please
find below the details you have inquired;</font></p>
<p align="center"> </p><br><br><br><br><br><br>
<p align="center"><strong><br>
<?php
$txtserial = $_POST['txtserial'];
// Make a MySQL Connection
mysql_connect("localhost", "bjventur_basha", "nagma@rajani11") or die(mysql_error());
mysql_select_db("bjventur_test") or die(mysql_error());
// Get a specific result from the "dikon" table
$result = mysql_query("SELECT * FROM bjventur_dikon
WHERE serial='$txtserial'") or die(mysql_error());
// get the first (and hopefully only) entry from the result
$row = mysql_fetch_array( $result );
if ($row == 0)
{
header('Location: http://www.website.com/missing.html');
}
else
{
}
// Print out the contents of each row into a table
echo " Serial Number: " .$row['serial'];
echo "<br />";
echo "<br />";
echo " Customer Name: ".$row['name'];
echo "<br />";
echo "<br />";
echo " Warranty upto: ".$row['warranty'];
?>
</strong></p>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<p align="center"><font color="#333333">For Service Please call at <strong>008-8803-333</strong></font></p>
<p align="center"><font color="#333333"><em>Thank you for visiting!</em></font></p>
<p> </p>
<p> </p>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center">
<p><font color="#666666" size="2" face="Arial, Helvetica, sans-serif">
</font></p>
<p><font color="#FFFFFF" size="1" face="Arial, Helvetica, sans-serif">Powered
by</font><font color="#666666" size="1" face="Arial, Helvetica, sans-serif">
<a href="http://www.website.com" target="_blank" style="text-decoration:none"><font color="#FFFFFF">nigil</font></a></font></p>
</div></td>
</tr>
</table>
<p> </p>
</BODY></HTML>