johnseito Posted February 25, 2008 Share Posted February 25, 2008 If i input this code Code: header("Location: " . $_SERVER['PHP_SELF']); after this code Code: mysql_query("insert into upload3(photo, caption) values('$fileName','$caption')"); this code won't print Code: echo "<font color =red> The file </font><b>". basename( $_FILES['uploaded']['name']). "</b> <font color=red>has been uploaded to the</font>". "<b> $dir </b></font>"."<font color=red> directory.</font><br><br>"; Code: mysql_query("insert into upload3(photo, caption) values('$fileName','$caption')"); header("Location: " . $_SERVER['PHP_SELF']); echo "<font color =red> The file </font><b>". basename( $_FILES['uploaded']['name']). "</b> <font color=red>has been uploaded to the</font>". "<b> $dir </b></font>"."<font color=red> directory.</font><br><br>"; Do you know why or how I can fix it? thanks Link to comment https://forums.phpfreaks.com/topic/92832-code-wont-print/ Share on other sites More sharing options...
Cagecrawler Posted February 25, 2008 Share Posted February 25, 2008 header("Location: " . $_SERVER['PHP_SELF']); The header("Location:.... function instantly redirects the script to the target location - anything after this point is ignored by the script and so will not be printed. If you want to show the text for a little while and then redirect, you should use the html <meta> tag. <?php echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"5; URL=".$_SERVER['PHP_SELF']."\">"; ?> You need to put this into the <head> tag of your page though, so it might not be appropriate. Link to comment https://forums.phpfreaks.com/topic/92832-code-wont-print/#findComment-475553 Share on other sites More sharing options...
revraz Posted February 25, 2008 Share Posted February 25, 2008 If you search on what header is actually for, you'll understand why. Link to comment https://forums.phpfreaks.com/topic/92832-code-wont-print/#findComment-475556 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.