弹出窗口关闭而不完成功能

Pop up window closed without completion of the function

本文关键字:成功 功能 窗口      更新时间:2023-09-26

我做了一个弹出窗口,有一个提交表单和提交后,它必须关闭,但我首先要处理的信息从弹出窗口在不同的页面,而不显示其他页面。我该怎么做呢?

我的弹出窗口包含以下代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"   
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script type="text/javascript">
            function closeSelf(){
                self.close();
                return true;
            }
        </script>
        <title>Add Activity</title>
    </head>
    <body>
        <form action="./addact.php" method="post" onsubmit ="return closeSelf()">
        <table width="500" border="1"><br/>
            <tr>
                <td>Activity Name</td>
                <td>Assigned Person</td>
                <td>Deadline</td>
            </tr>
            <tr>
                <td> <input name="activities" type="text" size="40%"/></td>
                <td><input name="name" type="text" size="40%"/></td>
                <td><input type="date" name="deadline" size="20%"/></td>
            </tr>
        </table>
        <input type="submit" name = "saved" id="saved"/>
        </form>
    </body>
</html>

和我的其他页面包含这个

<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Untitled Document</title>
    </head>
    <?php
        include('config.php');
        $actname= $_POST['activities'];
        $assigned = $_POST['name'];
        $deadline = $_POST ['deadline'];
        $sql = "INSERT INTO ".$_SESSION['pname']."_activities 
                (actname, assigned, deadline) 
            VALUES 
                ('$actname', '$assigned', '$deadline')
        ";
        $query = mysql_query($sql);
        echo $_SESSION['pname'];
    ?>
    <body>
    </body>
</html>

应该在返回响应时关闭窗口,而不是在提交页面时关闭窗口。正如@Marc B所指出的,你们有重大的安全问题!