2010-12-03 61 views
2

我正在構建基於iframe的 - facebook應用程序。我的問題是,無論何時將用戶重定向到任何頁面,我都可以看到頁面加載了兩次。 (首先,它顯示沒有css的頁面,然後再次用css加載頁面)。我發佈任何表單時也是如此。facebook應用程序 - 一切都發布兩次 - 基於iframe的應用程序

因此,每個表單都發布兩次。數據爲每個動作添加兩次。此外,我可以在url中看到我的所有POST數據... Facebook正在將所有會話數據傳遞給URL。這是正常的嗎?

我錯過了什麼嗎?請幫幫我。以下是我的代碼。

foreach($records as $product_list) 
{ 
?> 
    <tr> 
    <td width="250"> 
     <form name="frm_product_<?php echo $product_list->product_id; ?>" id="frm_product_<?php echo $product_list-> product_id; ?>" action="cart.php"> 
     <?php echo $product_list->product_name; ?><br /> 
     Price : <?php echo $product_list->price; ?>&nbsp;SGD<br /> 
     <input type="hidden" name="product_id" value="<?php echo $product_list->product_id; ?>" /> 
     <input type="submit" name="btn_submit_<?php echo $product_list->product_id; ?>" id="btn_submit_<?php echo $product_list->product_id; ?>" value="Add to Cart" /> 
     <input type="hidden" name="action" value="add" /> 
     </form> 
    </td> 
    </tr> 
    <tr> 
    <td>&nbsp;</td> 
    </tr> 
<?php 
} 
?> 

if(isset($_REQUEST['action']) && $_REQUEST['action']=='add') 
{ 

    $cart = new Cart($db); 
    $cart->user_id = 1; 
    $cart->product_id = $_REQUEST['product_id']; 
    $cart->qty = 1; 
    $cart->add_to_cart1(); //this is adding items two times 
} 

在此先感謝。

+0

很難說什麼導致你的雙輸出/ CSS問題,但我可以回答你的問題網址中的數據。 「

」元素的默認`方法'是GET,它指定表單數據在url中編碼。要隱藏表單信息,請使用POST:``。有關更多詳細信息,請參見[W3頁面](http://www.w3.org/TR/html401/interact/forms.html#adef-method)。 – 2010-12-03 04:52:51

回答

0

對於雙後期問題總是檢查你沒有某個圖像href設置爲''(空字符串)的地方。 它是一個css中的一個或一個url()。 這不是一個問題,而是HTTP中的設計決定,空的GET url(如空的圖像src)意味着redio讓你在頁面上的請求(可能是POST)。 這可能不是你的情況,但最後一次我是這樣,它花了我3天的時間找到:-)