title: Send data to PayPal; submit with PHP
body: <p>This is my code:</p>
  
  <pre><code>&lt;form action="" method="post"&gt;
  &lt;input class="payment_input" type="text" name="name" placeholder="Name"&gt;
  &lt;input class="payment_input" type="text" name="address" placeholder="Address"&gt;
  &lt;input class="payment_input" type="text" name="email" placeholder="E-mail"&gt;&lt;br&gt;
  &lt;input class="payment_input" type="submit" name="submit_paypal" value="Go to PayPal"&gt;
  &lt;/form&gt;
  
  &lt;?php
  $order_token = md5(uniqid($_POST['name'], true)); 
  
  if (isset($_POST["submit_paypal"])) {
  
  $statement = $pdo-&gt;prepare("INSERT INTO customers (name, address, email, order_token) VALUES (:name, :address, :email, :order_token)");
  $statement-&gt;execute(array(':name' =&gt; $_POST['name'], ':address' =&gt; $_POST['address'], ':email' =&gt; $_POST['email'], ':order_token' =&gt; $order_token));
  
  echo "
  &lt;form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\"&gt;
  &lt;input type=\"hidden\" name=\"cmd\" value=\"_xclick\"&gt;
  &lt;input type=\"hidden\" name=\"business\" value=\"test@icloud.com\"&gt;
  
  &lt;input type=\"hidden\" name=\"item_name\" value=\"eBook\"&gt;
  &lt;input type=\"hidden\" name=\"amount\" value=\"10\"&gt;
  &lt;input type=\"hidden\" name=\"return\" value=\"http://www.example.com/book.php?payment=success&amp;orderToken=".$order_token."\"&gt;
  &lt;input type=\"hidden\" name=\"cancel_return\" value=\"http://example.com/book.php?payment=canceled\"&gt;
  &lt;input type=\"submit\"&gt;
  &lt;/form&gt;
  ";
  }
  ?&gt;
  </code></pre>
  
  <p><strong>It woks as follows:</strong> User gets a form to insert his data (name, address, email). When the user submits the form two things should happen: User data get stored im my database with a random order_token. This order_token is needed to identify the user data when payment is done. (When the order_token e.g. is "5dcb567fb34805d45d55218995df12f5", the PayPal return link (if payment successful) is "<a href="http://www.example.com/book.php?payment=success&amp;orderToken=5dcb567fb34805d45d55218995df12f5" rel="nofollow noreferrer">http://www.example.com/book.php?payment=success&amp;orderToken=5dcb567fb34805d45d55218995df12f5</a>").</p>
  
  <p>But I have two problems:</p>
  
  <ol>
  <li><p>How to submit the PayPal form as soon as the user submits the order form on my website without the need to make another submit button the user have to click?</p></li>
  <li><p>How to prevent that user can manipulate the PayPal form? Currently a user could simply change the amount from e.g. 10 to 1.</p></li>
  </ol>
  
  <p>I hope somebody has the energy to help me because I'm already working on it since nights.</p>