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

Recommended Answers

All 3 Replies

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.