facebook application - everything is posted twice - iframe-based application
I am building an iframe based - facebook application. My problem is, whenever I redirect user to any page, I can see pages are loaded twice. (first, it shows the page without css and then again page is loaded with css). Same is happening when I post any form.
So, every form is posted twice. Data is added twice for each and every action. Moreover, I can see all my POST data in url... facebook is passing all session data in URL. Is it normal?
Am I missing something? Please help me. Below is my code.
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; ?> 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> </开发者_C百科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
}
Thanks in advance.
For double post problems always check you do not have somewhere an image href set to '' (empty string). It colud be an or an url() in a css. This is not an issue but a design decision in HTTP, empty GET url (like an empty image src) means redio the request that get you on the page (that could be a POST). It's maybe not your case, but last time I was it by that it took me 3 days to find :-)
精彩评论