弹出窗口关闭但未完成该功能

时间:2013-01-18 17:21:36

标签: php javascript mysql

我创建了一个提交表单的弹出窗口,提交后必须关闭,但我首先想要在不同的页面中弹出窗口中的信息,而不显示其他页面。我该怎么办?

我的popupwindow包含此代码

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

1 个答案:

答案 0 :(得分:0)

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