Postingan lainnya
Notifikasi Pesan
hallo gan,
ada punya script untuk menampilkan pesan :
<?php
include "config.php";
$id =$_GET['id'];
$query =mysql_query("DELETE FROM nama_tabel WHERE id='$id'");
if($query){
echo '<script language="javascript">swal({
title: "Warning!",
text: "nik and confirm nik do not match !",
type: "warning"
}, function(){
window.location.href = "index.php";
});</script>';
?>
tetapi pesan tersebut tidak muncul ? mohon bantuannya. terima kasih.
5 Jawaban:
coba ini gan, <pre> $query =mysql_query("DELETE FROM nama_tabel WHERE id='$id'"); if($query){ echo '<script type="text/javascript"> swal({ title: "Warning!", text: "nik and confirm nik do not match !", type: "warning" }).then((result) => { window.location.href = "https://www.sekolahkoding.com"; }) </script>'; } </pre>
tetap tidak muncul gan, ane open console ada error seperti ini : <a href='https://www.dropbox.com/home/TEST?preview=error.PNG '>https://www.dropbox.com/home/TEST?preview=error.PNG </a>
<pre> <script type="text/javascript"> swal({Uncaught ReferenceError: swal is not defined title: "Warning!", text: "nik and confirm nik do not match !", type: "warning" }).then((result) => { window.location.href = "https://www.sekolahkoding.com"; }) </pre>
Jawaban Terpilih
sepertinya masalah di $querynya, coba ini
<pre> if(!mysql_query("DELETE FROM nama_tabel WHERE id='$id'")){ //jika query delete gagal echo '<script type="text/javascript"> swal({ title: "Warning!", text: "nik and confirm nik do not match !", type: "warning" }).then((result) => { window.location.href = "https://www.sekolahkoding.com"; }) </script>'; } </pre>