Reputation: 871
.guys I have the following code:
echo ("<SCRIPT LANGUAGE='JavaScript'>
window.alert('Succesfully Updated')
</SCRIPT>");
what i want to do is that when i click ok on the windows.alert the page will be redirected to a my edit.php.
or how is it possible to create a javascript which will execute an insert query.
Upvotes: 11
Views: 169185
Reputation: 3703
If you would like to redirect the user after the alert, do this:
echo ("<script LANGUAGE='JavaScript'>
window.alert('Succesfully Updated');
window.location.href='<URL to redirect to>';
</script>");
Upvotes: 3
Reputation: 34632
Alert will block the program flow so you can just write the following.
echo ("<script LANGUAGE='JavaScript'>
window.alert('Succesfully Updated');
window.location.href='http://someplace.com';
</script>");
Upvotes: 37
Reputation: 33
Use this if you also want to consider non-javascript users:
echo ("<SCRIPT LANGUAGE='JavaScript'>
window.alert('Succesfully Updated')
window.location.href='http://someplace.com';
</SCRIPT>
<NOSCRIPT>
<a href='http://someplace.com'>Successfully Updated. Click here if you are not redirected.</a>
</NOSCRIPT>");
Upvotes: 1
Reputation: 16419
You could do this:
echo "<script>alert('Successfully Updated'); window.location = './edit.php';</script>";
Upvotes: 3