加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

使用php和javascript显示警报框

发布时间:2020-12-13 16:51:28 所属栏目:PHP教程 来源:网络整理
导读:if (!(isset($_POST['fullname']) strlen($_POST['fullname']))) { echo "script type="text/javascript"". "window.alert('You must enter your full name.');". "/script"; exit; } 上面的代码在register.php文件中.我在index.html中有html表单.当我发布
if (!(isset($_POST['fullname']) && strlen($_POST['fullname']))) {
  echo 
  "<script type="text/javascript">".
  "window.alert('You must enter your full name.');".
  "</script>"; 

   exit;             
}

上面的代码在register.php文件中.我在index.html中有html表单.当我发布没有全名的表格.它显示警报但页面卡在register.php(空白页.)
我想在index.html页面上显示警报或至少被重定向到index.html.
怎么做???

解决方法

在脚本中尝试window.location.href =’/ index.html

if (! (isset($_POST['fullname']) && strlen($_POST['fullname']))) {
    echo "<script type="text/javascript">window.alert('You must enter your full name.');window.location.href = '/index.html';</script>"; 
   exit;
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读