It is showing following error on execution of my program- Warning: Cannot modify header information - headers already sent by (output started at /home/sanganak/public_html/dwarka_parichay_copy/add.php:10) in /home/sanganak/public_html/dwarka_parichay_copy/add.php on line 24 My code is - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php $con = mysql_connect("localhost","sanganak_manish","manish"); if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("sanganak_mydata",$con); $s = $_POST['name']; //$p="mohan"; echo $s; echo $p; ob_start(); if($s == "mohan") { header('Location:http://sanganak.co.in/dwarka_parichay_copy/useful_links.htm'); } mysql_close($con); ?> </body> </html>
You can't output any content if your sending a header(); unless you use the ob_... function(s) list before any output. But the better way is to rearrange your code, so it uses the logic that it really needed to begin with. So move the "ob_start();" up to the beginning of your script, right before "<!DOCTYPE...", add... <?php ob_start (); ?> PHP: