简体   繁体   English

PHP Javascript:关闭弹出式窗口,在后台调用父窗口

[英]PHP Javascript: Closing Popup calling parent window in background

Let's say a parent window is www.mysite.com/index.php has several links. 假设一个父窗口是www.mysite.com/index.php有几个链接。 When user clicks on these links, a popup is opened. 当用户单击这些链接时,将打开一个弹出窗口。

The popup has some forms. 弹出窗口具有某些形式。 When the user clicks submit button, another script is called within the popup like this: 当用户单击“提交”按钮时,将在弹出窗口中调用另一个脚本,如下所示:

if ((isset($_POST['Complete'])) && ($_POST['Complete']=='Complete')) {
    unset($_POST['Complete']);

    include 'result.php';

    return;
}

The result.php enters the data into database and pass the result to parent window with the following result.php将数据输入数据库,并将结果传递给具有以下内容的父窗口

<script language="JavaScript" type="text/javascript">
    window.opener.location.href = 'submission.php';
    window.close();
</script>

The parent window then show the final result, update the master database and emails the users. 然后,父窗口将显示最终结果,更新主数据库并通过电子邮件发送给用户。

Now here is the problem. 现在这是问题所在。

  1. User clicks the link on parents. 用户单击父母上的链接。
  2. Form opens, but user click close (browser cross button). 表单打开,但用户单击关闭(浏览器十字按钮)。
  3. The user then closes parent window 然后,用户关闭父窗口
  4. The user then visit some other page of the site; 然后,用户访问网站的其他页面; say other.php 说other.php
  5. But the master database is getting updated and the user is getting the email (All null values though). 但是主数据库正在更新,而用户正在接收电子邮件(尽管所有null )。

Since the form was never completed, the result.php should never be called. 由于表单从未完成,因此永远不要调用result.php and if result.php is never called, submission.php should never be called. 如果从不调用result.php则永远不应调用result.php

What is happening here? 这是怎么回事

将关闭按钮的类型更改为button。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM