weixin_33671935 2017-05-22 07:35 采纳率: 0%
浏览 50

JavaScript警报标头

I write 2 php pages, index.php & form.php, when user submit form in index.php, then form.php process and check whether email is duplicate, so I write in form.php like this

header('Content-type:text/html; charset=big5');
header("location:javascript://history.go(-1)");
echo "<Script language=JavaScript>alert('email exist!');</Script>";

if the email exist, page will return to index.php, I hope the input text box still keep what the user enter, and have a alert box in index.php to remind them the email exist,

But I try different way, but the alert box cannot be shown in index.php, I know nothing will output before header, I also try ob_start(),

Can anyone teach me how can I check email duplication in form.php, and then just go back to index.php without refresh, also the user input still appear, also index.php can display an alert box to remind user, thank you!

  • 写回答

2条回答 默认 最新

  • ??yy 2017-05-22 07:36
    关注

    it should be script NOT Script

    echo "<script type='text/javascript'>alert('email exist!');</script>";
    

    EDIT : if you are redirecting back to index.php and the alert is in form.php so it will never fire you have to be on the same page!

    评论

报告相同问题?

悬赏问题

  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题