Click here to Skip to main content
15,886,963 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am getting error for headers already sent
PHP
<?php
 $telecaller = (isset($_GET['telecaller'])) ? $_GET['telecaller'] : null;

XML
<?php
 $telecaller = (isset($_GET['telecaller'])) ? $_GET['telecaller'] : null;
?>
<html>
 <head>
 <title>Edit Record</title>
 <script>
 </script>
 </head>
 <body>
 <form action="#" method="post">
 <input type="hidden" name="id" value="<?php echo $telecaller; ?>"/>
 <div>
 <strong> Name of CIExe.</strong> <input type="text" name="telecaller" value="<?php echo $telecaller; ?>"/><br/>
 <input type="submit" name="submit" value="Submit">
 </div>
 </form>
 </body>
 </html>
 <?php
 include 'db.php';
 if (isset($_POST['submit'])) {
 $con=mysql_query("UPDATE import2 SET telecaller='$_POST[telecaller]' WHERE telecaller='$telecaller'")
 or die(mysql_error());
if(!$con){
    echo 'can not update';
}else {
header('location:ntelecaller.php');
}
}
?>
Posted

1 solution

The issue you are facing is caused by the header instruction you have at the bottom of the script. PHP already started sending the HTML to the client, hence you cannot sent the headers again.

Things are transmitted as follows:
1. Header information
2. Page content

If you move the PHP code at the bottom up to the top of the page the issue should dissapear. I included the sample below that should fix the issue.

PHP
 $telecaller = (isset($_GET['telecaller'])) ? $_GET['telecaller'] : null;
 include 'db.php';
 if (isset($_POST['submit'])) {
 $con=mysql_query("UPDATE import2 SET telecaller='$_POST[telecaller]' WHERE telecaller='$telecaller'")
 or die(mysql_error());
if(!$con){
    echo 'can not update';
}else {
header('location:ntelecaller.php');
}
}
?>
<html>
 <head>
 <title>Edit Record</title>
 <script>
 </script>
 </head>
 <body>
 <form action="#" method="post">
 <input type="hidden" name="id" value="<?php echo $telecaller; ??>"/>
 <div>
  Name of CIExe. <input type="text" name="telecaller" value="<?php echo $telecaller; ??>"/><br />
 <input type="submit" name="submit" value="Submit">
 </div>
 </form>
 </body>
 </html>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900