0

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

2
Contributors
3
Replies
6
Views
7 Years
Discussion Span
Last Post by nonshatter
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

Edited by nonshatter: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.