2013-01-18 54 views
0

我做了一个弹出式窗口,提交表单,提交后它必须关闭,但我首先想要在弹出窗口中处理不同页面中的信息而不显示那个其他页面。我该怎么做?弹出窗口关闭没有完成的功能

我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> 
+4

停止对此工作并在继续之前阅读[sql注入攻击]](http://bobby-tables.com)。你只是乞求让你的服务器pwn3d。 –

+0

您应该查看AJAX表单提交。并绑定提交按钮或onsubmit事件的'onclick'以关闭弹出窗口。 –

+0

@Marc B感谢您的警告。我会阅读保护我的代码。我不知道从哪里开始。大声笑!但非常感谢! –

回答

0

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

+0

感谢您的提示:) –