954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

paypal in a form

Hi i have a form which also uses php to insert records into database, just name and address but also need them to pay via paypal, please help

Form code

<form action="insert.php" method="post">
  <div align="center">Firstname: 
    <input type="text" name="firstname" />
    Lastname: 
  <input type="text" name="lastname" />
    Email: 
  <input type="text" name="email" />
  <input type="submit" />
  </div>
</form> 
<div align="center">

insert.php code

<?php
$con = mysql_connect("x","x","x");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("databasename", $con);

$sql="INSERT INTO Persons (FirstName, LastName, Email)
VALUES
('$_POST[firstname]','$_POST[lastname]','$_POST[email]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }

$to = "mymail"; //Your email address
$subject = " Paying member"; //Email subject
$message = "new details have been entered into the database"; //Body of email
mail($to, $subject, $message);
	  
echo "Thank you you will recieve information shortly";

mysql_close($con)
?>

thanks

mpc123
Junior Poster in Training
50 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
 

You will need to get a PayPal button from the paypal website. From what I remember, there are two types or button, an encrypted one or an unencrypted one. I think you need an unencrypted one if you wish to plug in your own php variables into the paypal form.

It uses hidden fields to pass paypal the payee and product details. E.g:

<form 
  action="https://www.paypal.com/cgi-bin/webscr" method="post">
  <input type="hidden" name="cmd" value="_xclick" />
  <input type="hidden" name="business" value="paypal@mywebsite.com" />
  <input type="hidden" name="return"
         value="http://www.mywebsite.com/thankyou.html" />
  <input type="hidden" name="item_name" value="Training Documents" />
  <input type="hidden" name="amount" value="25.00" />
  <input type="submit" value="Buy Now!" />
</form>


Here's a good link for some requisite research http://en.csharp-online.net/Encrypted_Website_Payments%E2%80%94PHP_Developers In addition, you may want to have a look at Instant Payment Notificaton (IPN) https://www.paypal.com/ipn

nonshatter
Posting Whiz
377 posts since Nov 2009
Reputation Points: 39
Solved Threads: 63
 

OK THANKS, how do i get that in with what i already have?

mpc123
Junior Poster in Training
50 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
 
nonshatter
Posting Whiz
377 posts since Nov 2009
Reputation Points: 39
Solved Threads: 63
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: