doudai8783 2016-03-14 07:38 采纳率: 100%
浏览 72
已采纳

确认页面重定向到原始页面并显示为JS通知

Gosh, that title was a bit of a mouthful.

Basically my question is quite hard to explain due to my bare knowledge of PHP but I have a contact form that once the submit button has been pressed, processes through an engine, then redirects to a confirmation page if all has worked out.

This confirmation page is a html document that is literally a h1 tag with some text, what I would like to do is have a confirmation show up on the original page with the contact form on it as a javascript notification (a NotifyJS type one)

My file structure: contact form: contact.html > contactengine.php (if no errors) > contactthanks.php

Here is the code

// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>

Here is the plugin I want to use for the error https://notifyjs.com/

This is my confirmation notification, that I want the contactthanks.php message to show up on (on the original page)

$.notify("Email sent succesfully");

Thanks in advance, been trying heaps of different things but I'm just getting nowhere, can't find any answers that make sense to me also.

  • 写回答

1条回答 默认 最新

  • dongmu1951 2016-03-14 08:38
    关注

    The flow does not seem clear.

    You want a notification on the form page but you wouldn't see it because you are forwarded to either "thankyou" or "error".

    I don't know exactly what you want but perhaps you want to fire the form through AJAX (which would execute it in the background and you stay on the form page) and then show the result (error or thankyou) in a notification.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度