2011-04-14 23 views
1

這裏的網站我建立的結構:頭位置:加載內容到頁面的div

我有first.php,其中包括second.php。

在second.php中我有一個鏈接到一個表單,我有$ _GET來獲取在這個結構的最後一頁發送的url參數。

form.php告訴action.php(此結構的最後一頁)切換案例是FORM。 內箱形狀,我有:

header("Location: second.php?param1=OK&param2=OK"); 

這一行我加載頁面second.php與參數,但我需要加載是包括與參數一起second.php這樣我就可以使用first.php頁面$ _GET

有什麼辦法可以做到嗎?在結構下面。

謝謝!

first.php

I'm the first page<br><br> 

<div style="width:500px;height:500px;border:2px solid red;"><?php include "second.php" ?></div> 

second.php

<?php 
$param1 = $_GET['param1']; 
$param2 = $_GET['param2']; 

?> 
<script language="javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script> 
<script> 

    $(document).ready(function(){ 

      $("#theform").click(function(theevent){ 
      $("#pre_target").html('<div id="target"></div>');    
       theform(); 
      }); 


}) 
      function theform() { 
      $("#target").load("form.php", {}, function(){ }); 

      } 

</script> 

I'm the second page 

<div id="pre_target"> 
    <a href="#" id="theform">Go to form</a> 
</div> 

form.php的

<form method="post" action="action.php"> 
    <input type="hidden" name="ACTION" value="FORM"> 
<input type="submit" value="submit" name="submit"> 
</form> 

action.php的

<?php 

switch($_REQUEST["ACTION"]) { 

    case "FORM": 

    header("Location: second.php#pre_target?param1=OK&param2=OK"); 

    break; 

    . 
    . 
    . 
    ?> 
+2

酷烏爾建設'web'?你如何做到這一點? :-p – Neal 2011-04-14 16:15:48

回答

2

如果我正確理解您的問題,只需將'second.php'替換爲'first.php'即可。 GET變量是超級全局變量,意思是超級變量和全局變量。如果first.php包含second.php,second.php和first.php將共享相同的GET變量。

header("Location: second.php?param1=OK&param2=OK"); 

更改爲:

header("Location: first.php?param1=OK&param2=OK"); 
+0

超全局!非常感謝! – user638009 2011-04-14 16:29:10