Xtrem fabz Xtrem fabz - 2 years ago 112
Javascript Question

javascript alert box not showing on php

I am trying to display an alert box before redirecting to another page, here is my code, when I remove the header function it works properly but when it is here it will just redirect to the page without showing the alert box.


$tempid = mysqli_real_escape_string($dbconfig, $_POST['tempid']);

$sql_query = "DELETE FROM Visits
WHERE visitid = '$tempid'";
$result = Mysqli_query($dbconfig, $sql_query);
if ($result) {

echo '<script language="javascript">';
echo 'alert("visit deleted successfully")';
echo '</script>';


Answer Source
echo "<script>
alert('visit deleted successfully');

and get rid of redirect line below.

You were mixing up two different worlds.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download