Code:
if(!$picture) $error = $error."<div>This is a photo site, we require you select a photo.</div>";
if(!$imgname) $error = $error."<div>You must enter a name for your photo.</div>";
if(!$description) $error = $error."<div>You must enter a description for your photo.</div>";
else if(strlen($description) > 500) $error = $error."<div>Your descriptions to long. 500 characters max.</div>";
if(!$error) {
$case = 2;
$max_width_new = 190;
$make_thumb=1; $make_medium=1; $make_original=1;
$imagename = "picture";
$folders = "accounts/".$dbid."/";
if(!file_exists($folders))
mkdir($folders);
include("scripts/php/uploadpicture.php");
if($file) {
$connect = mysql_connect("localhost","headinth_admin","adobe1234");
mysql_select_db("headinth_core");
mysql_query("INSERT INTO pictures (id, uploader, name, description, location, picture, date) VALUES('','$dbid','$imgname','$description','$location','$file_name','$date')");
$_SESSION['uploaded'] = 1;
header("location: ?upload");
}
} else echo "<div class='green f18 fl coolvetica' style='text-align:left;'>".$error."</div><div class='c20'></div>";
}
if(isset($_SESSION['uploaded'])) {
echo "<div class='white f18 fl coolvetica' style='text-align:left;'>Your picture was uploaded.</div><div class='c20'></div>";
unset($_SESSION['uploaded']);
}
?>
So it goes through and if everything successful it declares $_SESSION[‘uploaded’] = 1. Makes sense. Since theres a header it refreshes the page. Then I check if $_SESSION[‘uploaded’] exists, to see if a photo was just uploaded. If it was then it should send the message “Your photos been uploaded”. Then it would have to delete the $_SESSION[‘uploaded’] variable so it doesn’t show up again if the page is refreshed or an invalid submission is made.
The issue is that its just skipping the if(isset($_SESSION[‘uploaded’])) line and just unsetting the session. So its not echoing the success message. IF i delete the unset it works, just always appears until the entire session is destroyed. So the goal, carry a variable over a page refresh, echo it then remove it.
header()doesn’t halt execution of your script. After theheader()command, the script continues to yourisset()/unset()block. The solution is todieafter theheader():