PHP redirect_to not working
<p>I am having an issue with PHP redirect_to. I have a form where a user can select an image to upload. Upon succussful upload I'd like the user to be redirected to a page that lists all images in the database. The following code comes from a PHP file called upload_image.php. It is in the same directory as the page I'd like to redirect to, list_images.php. I've narrowed down the problem area to the following code:</p>

<pre><code>if(isset($_POST['submit'])){
$image = new Image();     //User defined class
$image-&gt;caption = $_POST['caption'];     //Places caption text field in the database
$image-&gt;attach_file($_FILES['file_upload']);     //Copies image to images folder

if($image-&gt;save()){
    //Success
    $session-&gt;message("Image uploaded successfully!");
    redirect_to('list_images.php');    //PROBLEM AREA. Page never redirects.
}else{
    //Failure
    $message = join("&lt;br /&gt;", $image-&gt;errors);
}}
</code></pre>

<p>My function for redirect_to() is the following:</p>

<pre><code>    function redirect_to($location = NULL){
if($location != NULL){
    header("Location: {$location}");
    exit;
}}
</code></pre>

<p>The uploaded image is always successfully copied to the correct location and its information gets stored in the database. After submitting however I am always left with a blank page and the url of upload_image.php in the browser. Through countless echo tests I've determined that the problem happens at redirect_to('list_images.php'); I am able to echo text onto the blank page just before redirect_to, but anything after redirect_to does not get executed.</p>

<p>Does anyone have any ideas to advice?</p>

<p>Thank you!</p>
