dscizpq790832708 2014-05-15 07:08
浏览 21
已采纳

确认框不显示并自动删除

HELP ME Please. I created a delete process wherein there i a confirm box to ask the user if he is sure or not. but the confirm box doesnt appear and automatically deletes the data and doesnt even redirect me. Help me plss!

I need to show the confirmation box ("are u sure") and if the input is true. it will delete the data and redirect to other page.

 <?php
 require_once('connect/connect.php');
 ?>
 <script>
 var r = confirm("Are you sure?");
 if (r == true)
 {
 alert(' item successfuly deleted!!');
 </script>
 <?php

 if(isset($_GET['pid'])){
$sql ='Select * FROM product where pid = '.$_GET['pid'];
$qry = mysql_query($sql);
$data = mysql_fetch_array($qry);
$pname = $data['pname'];
$pstock = $data['pstock'];
}
$sq3="INSERT INTO report VALUES('NULL','".$pname."', '" .$pstock. "', 'Item Deleted' )";
$qry3 = mysql_query($sq3);

$sql2 = 'DELETE FROM product where pid = '.$_GET['pid'];
$qry2 = mysql_query($sql2);
?>
<script>
 window.location.assign('products.php');    
 }
 </script>
 <script>
 else
 {
window.location.assign('products.php');
 }
</script>
  • 写回答

3条回答 默认 最新

  • dtvp3625 2014-05-15 07:10
    关注

    you missed the closing brace } of if condition

     <script>
     var r = confirm("Are you sure?");
     if (r == true)
     {
     alert(' item successfuly deleted!!');
     }
     </script>
    

    FIDDLE

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程