2014-01-18 28 views
0

因爲我使用PayPal和BlueSnap我有兩個不同的IPN,當他們都在頁面上時似乎有一個問題,如果我拿走一個然後他們將工作真的需要這個工作花了幾個小時試圖弄清楚:/錯誤使用後兩次?

<?php 
    /** 
    * If the player clicks the continue 
    * button, it will perform the following 
    * process. The process will redirect to 
    * the checkout URL as long as the player 
    * has entered their username details. 
    */ 
    if (isset($_POST['continue'])) { 
     $username = trim($_POST['username']); 
     $product = trim($_POST['product']); 
     if ($username != "Enter Username" && $username != "") { 
      header("Location: http://www.plimus.com/jsp/buynow.jsp?contractId=" . $product . "&custom1=" . $username); 
      exit; 
     } 
    } 
?> 
<html> 

      <form action="<?php ?>" method="POST"> 
       <div name="select"> 
        Product: 
        <select name="product"> 

        </select> 
       </div> 
       <div name="username"> 
        Username: 
        <input type="text" maxlength="12" name="username" value="Enter Username" onblur="if(this.value=='') this.value='Enter Username';" onfocus="if(this.value=='Enter Username') this.value='';"/> 
       </div> 
       <?php 
        /** 
        * If the user enters their username details 
        * incorrectly, it will perform this process. 
        * This will just send a line of text asking 
        * them to enter their username. I recommend 
        * carrying over this process when you integrate 
        * it with your own website theme. 
        */ 
        if (isset($_POST['continue'])) 
         echo "<font color=red>Please enter your username.</font>"; 
       ?> 
       <div name="button"> 
        <button type="submit" name="continue" value="Continue">Continue</button> 
       </div> 
      </form> 
<a href="http://www.plimus.com/ecommerce/buyers" target="_blank" title="Trusted and Secure Online Payment Processing via PLIMUS"><img src="https://www.plimus.com/images/icons_wizard/icons/cards/cards_type2_1-1.gif" border="0"></a> 
      </center> 

      <br> 

      <br> 
<center> 
<?php 

    if(isset($_POST['submit'])) { 
     $errors = array(); 

     $user = trim($_POST['user']); 
     $prod = trim($_POST['prod']); 
     header("Location: paypal.php?username=". $user ."&prod=". $prod); 
     exit; 
    } 

?> 

    <form action="<?php echo basename($_SERVER['PHP_SELF']); ?>" method="POST"> 
    <tr><td><center> 
     <table> 
      <select name="prod"> 


      </select> </td></tr> 
      <tr> 
       <td>Username:</td> 
       <td><input type="text" name="user" value="" /></td> <td colspan="2"><input type="submit" name="submit" value="Submit" /></td> 
      </tr> 
      </table> 
      </form> 

回答

0

假設您將處理過的數據存儲到某種形式的數據庫中。
我所要做的就是像平常一樣存儲數據,然後運行快速選擇以確保沒有雙重提交。 這也假設你已經消毒/驗證了POSTDATA

$check = mysqli_query($link, "SELECT `id` FROM `ipn_data` WHERE `txn_id` = '".$_POST['txn_id']."'"); 
if(mysqli_num_rows($check)) 
    exit("You've already submitted this payment"); 
mysqli_query($link, "INSERT INTO `ipn_data` (`custom`, `txn_id`) VALUES (".$_POST['custom'].", '".$_POST['txn_id']."')"); 

類似的規定。
我可應要求提供我的貝寶IPN類

<form action="someaction.php" name="paypal" method="post">
<form action="someaction.php" name="plimus" method="post">
然後只需運行一個檢查,看看哪些形式發佈:
if(isset($_POST['paypal']))
if(isset($_POST['plimus']))

+0

這並不是說我琬這只是你選擇你想購買物品的頁面,因爲我使用了「post」方法兩次,所以我不能讓它們在同一頁面上,你可以在這裏看到http://boomscape.co。英國/ donate.php&這裏是我的貝寶捐贈頁面http://boomscape.co.uk/donatepp.php時,他們在一起的貝寶不再工作:S – user3208776

+0

啊,我明白了。你有沒有嘗試命名形式不同? '

'和''然後簡單地運行一個檢查是否發佈了哪些表單:'if(isset($ _ POST ['paypal']))'if'isset($ _ POST ['plimus'])) 我將更新原始文章,原因是關於評論的格式不是很好 – Magictallguy

+0

我試過,沒有工作的人:/它是如此煩人不得不爲我的東西使用2個不同的頁面:/ – user3208776