How to redirect after Success

The script I’m using allows you to upload an image and has a Success message on the page.
Instead, I’d like it to re-direct to another page after a successful upload.
Here is part of the file code:

     // show success and message
    unset($_SESSION['security_token']);
    $security_token = randomcode();
    $_SESSION['security_token'] = $security_token;

    $template = "themes/$user_theme/templates/inner_upload_avatar.htm";
    $TBS = new clsTinyButStrong;
    $TBS->NoErr = true;

    $TBS->LoadTemplate("$template");
    $TBS->Render = TBS_OUTPUT;
    $TBS->tbs_show();

    @mysql_close();
    die();

} else { // proceed is false - show error msg

    $show_notification = 1;
    unset($_SESSION['security_token']);
    $security_token = randomcode();
    $_SESSION['security_token'] = $security_token;

    $template = "themes/$user_theme/templates/inner_upload_avatar.htm";
    $TBS = new clsTinyButStrong;
    $TBS->NoErr = true;

    $TBS->LoadTemplate("$template");
    $TBS->Render = TBS_OUTPUT;
    $TBS->tbs_show();
    @mysql_close();
    die();
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// sub functions

function die_with_msg($message) {
    $show_notification = 1;
    $template = "themes/$user_theme/templates/inner_upload_avatar.htm";
    $TBS = new clsTinyButStrong;
    $TBS->NoErr = true;
    $TBS->LoadTemplate("$template");
    $TBS->Render = TBS_OUTPUT;
    $TBS->tbs_show();
    @mysql_close();
    die();

}

Can you tell me if this is the section where it creates a successful message?
And if so, can you help me with an example of how to then re-direct (after success) to another page?

If you just want it to display the message, make the message page an include:-

include_once $_SERVER["DOCUMENT_ROOT"]."/includes/html/success.php";

But if you want an actual redirect to another page you can use a header redirect:-

header('location: path-to/success/');

Be aware that the mysql_* functions that you’ve used were removed from version 7 of PHP You should now be using the mysqli_* extension or PDO. Also it’s considered bad practice to just surpress errors with the error supression operator, any errors should be handled and logged (never displayed if it’s a live site)

Rewrite sorry

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.