Reputation: 7
if (isset($_POST['tambah'])) {
$id_wilayah = $_POST['id_wilayah'];
$nama_wilayah = $_POST['nama_wilayah'];
$_wilayah = "INSERT INTO wilayah_desa VALUES (?, ?, '')";
$stmt = mysqli_prepare($link,$_wilayah);
mysqli_stmt_bind_param($stmt, 'ss', $id_wilayah, $nama_wilayah);
mysqli_stmt_execute($stmt);
echo "<script language=\"JavaScript\">alert('Data Wilayah Desa Berhasil Disimpan!');</script>";
header('location:wilayah.php');
the Javascript alert is not working. is there anything wrong? I appreciate all answer. thank you
Upvotes: 0
Views: 402
Reputation: 11759
Try this...
echo "<script>alert('Data Wilayah Desa Berhasil Disimpan!');</script>";
But its likely not working because the header is redirecting you before the script fires
Upvotes: 0
Reputation: 572
The problem is not with Javascript; It's because that you added: header('location:wilayah.php'); it will instantly go there without even trying to apply the script removed it and worked for me ^_^
Upvotes: 4
Reputation: 14139
It should be type="text/javascript
, instead of language="Javascript. Heck, if I recall correctly, you don't even need this. Try:
echo "<script>alert('Data Wilayah Desa Berhasil Disimpan!');</script>";
Upvotes: 0