0

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

我的弹出窗口包含此代码

<!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>
4

1 回答 1

0

您应该在返回响应时关闭窗口,而不是在提交页面时。正如@Marc B 指出的那样,您遇到了重大的安全问题!

于 2013-01-18T17:24:49.760 回答