sammy
sammy

Reputation: 717

run a if step by step PHP

i have a problem in PHP, i want first show a message like this:

echo '<script language="javascript">';
echo 'alert("message successfully sent")';
echo '</script>';

and when i clicked on ok, then redirect to another page, my code is like this:

$fgmembersite->RedirectToURL("home2.php");

complete code:

if(isset($_POST['submitted']))
{ 
echo '<script language="javascript">';
echo 'alert("message successfully sent")';
echo '</script>';
$fgmembersite->RedirectToURL("home2.php");
}

but this code do not show me the message just redirect to home2.php, if there is another way except of 'if' please explain. the simplest way
thanks

Upvotes: 3

Views: 85

Answers (2)

Niranjan N Raju
Niranjan N Raju

Reputation: 11987

you should use javascript o redirect only. You are trying to mix, both php and javascript

echo "<script>javascript:alert('message successfully sent'); window.location = 'home2.php'</script>";

Upvotes: 1

Firas Rassas
Firas Rassas

Reputation: 509

If you just want to redirect to another page.. you can do this:

echo '<script language="javascript">';
echo 'alert("message successfully sent")';
echo '</script>';
echo '<script>window.location.href = "the-target-page.php";</script>';

Upvotes: 1

Related Questions