Jump to content

[SOLVED] redirect at end of script?


crispweasel

Recommended Posts

i modified eric o'calaghan's sms script to work without teleflip, but can't make it redirect correctly after message is sent

 

this is what i have now

 

        // Where are we sending it?
        $to = "" . $number . $carsuf;
        
        //Where is it coming from
        $header = "From: ". $name . " <" . $email . ">\r\n";
        
        // Add signature to message
        $messig = "" . $message . $signature;

        // Send the text message
        if (@mail($to, $subject, $messig, $header)) {

            // Give a success notice
            echo "<center>";
            echo "SMS/Text Messenger";
            echo "<br>";
            echo "Text message sent.";
            echo "<br>";
            echo "Please Use Your Browser's Back Button To Return";
            echo "</center>\n";
            echo "</body>\n";
            echo "</html>\n";
            exit;

        // Give an error that message can't be sent
        } else {
            $error = "Sorry, there was an error while trying to send the message - please try again later.";
        }
    }
}

// Show any errors encountered
if (isset($error)) {
    echo "<font color=\"red\"><b>" . $error . "</b></font><br><br>\n";
}
?>

 

 

 

what do i need to change to send back to my website and not to a cheesy blank page?

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/125735-solved-redirect-at-end-of-script/
Share on other sites

If you're going to output a success message, you will have to use a

<meta http-equiv="refresh" url="3;http://yoururl.com" />

 

In this manner, you can't force them to redirect.

 

fyi: 3 = time in seconds before redirect occurs

 

@maq

You can't use header() if he outputs a success message on that page!

header('Location:http://www.php.net');

 

Or you could use JS if this throws you an error (about headers), but it shouldn't.

 

 

header gives me an error

 

i tried this

header("Refresh: 3;url=http://www.textmyex.com");

 

js?

 

i am fairly new to coding

Well, i see Maq just posted it but here's mine anyway.

 

How about:

<?php
if(SUCCESS){
    echo "<script type='text/javascript'>window.location.href='gotopage.php'</script>";
}
?>

 

You could even use setTimeout() to add a count down or delay so they have a chance to see the message first.

Well, i see Maq just posted it but here's mine anyway.

 

How about:

<?php
if(SUCCESS){
     echo "<script type='text/javascript'>window.location.href='gotopage.php'</script>";
}
?>

 

You could even use setTimeout() to add a count down or delay so they have a chance to see the message first.

 

 

mark this one solved

 

 

THANK YOU!!!

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.