2013-01-18 90 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

感謝您的提示:) –