Jump to content

Code won't print


johnseito

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.