sama Posted March 13, 2010 Share Posted March 13, 2010 Hello what I did wrong that this warning occur: Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\xampp\htdocs\radio2_test.php: in C:\xampp\xampp\htdocs\radio2_test.php on line 57 what I should do? here is my code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']?>"> <p> <label> <input type="text" name="t1" id="textfield" /> </label> </p> <p> <br /> <?php $cxn = mysqli_connect("localhost","root","","nana") or die("Query died: connect"); $sql = "SELECT slot FROM times"; $result= mysqli_query($cxn,$sql)or die("Query died: Username"); while ($row=mysqli_fetch_array($result)) { $value=$row['slot']; echo "<input type='radio' name='check' value='$value' >$value<br>" ; echo "</br>"; } ?> <input type="submit" name="b1" id="button" value="Submit" /> </label> <br> </p> </form> <?php if (isset($_POST['b1'])) { $username=$_POST['t1']; $selection=$_POST['check']; $sql="INSERT INTO test (username,time) VALUES ('$username','$selection')"; mysqli_query($cxn,$sql); $sql1 = "SELECT slot FROM times"; $result1= mysqli_query($cxn,$sql1)or die("Query died: Username"); while ($row=mysqli_fetch_array($result1)) { $sql1="DELETE FROM times WHERE slot='$selection' "; mysqli_query($cxn,$sql1); } header ("Location: secret_page2.php"); } ?> <body> </body> </html> Link to comment https://forums.phpfreaks.com/topic/195144-error-in-directing-to-another-page/ Share on other sites More sharing options...
ram4nd Posted March 13, 2010 Share Posted March 13, 2010 echo the html in the end of the code Link to comment https://forums.phpfreaks.com/topic/195144-error-in-directing-to-another-page/#findComment-1025692 Share on other sites More sharing options...
PFMaBiSmAd Posted March 13, 2010 Share Posted March 13, 2010 what I should do? Put the php code that determines if you are going to redirect at the top of the page. Link to comment https://forums.phpfreaks.com/topic/195144-error-in-directing-to-another-page/#findComment-1025694 Share on other sites More sharing options...
sama Posted March 13, 2010 Author Share Posted March 13, 2010 what I should do? Put the php code that determines if you are going to redirect at the top of the page. Hello, Thanks a lot for the replay...but it still the same error :'(, here is the warning: Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\xampp\htdocs\radio2_test.php: in C:\xampp\xampp\htdocs\radio2_test.php on line 27 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <?php $cxn = mysqli_connect("localhost","root","","nana") or die("Query died: connect"); if (isset($_POST['b1'])) { $username=$_POST['t1']; $selection=$_POST['check']; $sql="INSERT INTO test (username,time) VALUES ('$username','$selection')"; mysqli_query($cxn,$sql); $sql1 = "SELECT slot FROM times"; $result1= mysqli_query($cxn,$sql1)or die("Query died: Username"); while ($row=mysqli_fetch_array($result1)) { $sql1="DELETE FROM times WHERE slot='$selection' "; mysqli_query($cxn,$sql1); } header ("Location: secret_page2.php"); } ?> <form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']?>"> <p> <label> <input type="text" name="t1" id="textfield" /> </label> </p> <p> <br /> <?php $cxn = mysqli_connect("localhost","root","","nana") or die("Query died: connect"); $sql = "SELECT slot FROM times"; $result= mysqli_query($cxn,$sql)or die("Query died: Username"); while ($row=mysqli_fetch_array($result)) { $value=$row['slot']; echo "<input type='radio' name='check' value='$value' >$value<br>" ; echo "</br>"; } ?> <input type="submit" name="b1" id="button" value="Submit" /> </label> <br> </p> </form> <body> </body> </html> Link to comment https://forums.phpfreaks.com/topic/195144-error-in-directing-to-another-page/#findComment-1025702 Share on other sites More sharing options...
PFMaBiSmAd Posted March 13, 2010 Share Posted March 13, 2010 You still have 7 lines of HTML being output before the php code that performs the redirect - 1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2. <html xmlns="http://www.w3.org/1999/xhtml"> 3. <head> 4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5. <title>Untitled Document</title> 6. </head> 7. <?php Link to comment https://forums.phpfreaks.com/topic/195144-error-in-directing-to-another-page/#findComment-1025746 Share on other sites More sharing options...
sama Posted March 14, 2010 Author Share Posted March 14, 2010 Dear PFMaBiSmAd I was so tired yesterday, so I just shut down my laptop & went to sleep. but the first thing I do in the morning is checking the forum, because I know that you will help me...Thank you...Thank you...Thank you... It is just solved! thanks for all the replies.. Link to comment https://forums.phpfreaks.com/topic/195144-error-in-directing-to-another-page/#findComment-1025817 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.