Jump to content

PHP Form with PayPal


Recommended Posts

Hi, I'm building a PHP form that asks a user a series of questions like name, email, phone etc, followed by some radio buttons. After the user has clicked the continue button it will send this info to an email address. If user has selected None for the reseller question then they will be shown a message saying someone will be in touch, if they have selected one of the other options then they will be able to purchase the product using PayPal.I need some help sending this data over to PayPal and allowing the user to purchase the product and then sending them back to the page afterwards with some form of thank you.This is the code I have so far:

<!DOCTYPE html><html lang="en">	<head>		<meta http-equiv="content-type" content="text/html; charset=utf-8">		<meta name="viewport" content="width=1024">		<title>Buy</title>	</head>		<body>			<?php				if(isset($_POST['continue']))				{			// Send info to email address						$to = "info@solidcamxpress.co.uk";			$subject = "SolidCAM Xpress";						$name_field = $_POST['name'];			$email_field = $_POST['email'];			$phone_field = $_POST['message'];			$company_field = $_POST['company'];			$reseller_field = $_POST['reseller'];			 			$body = "From: $name_field\n E-Mail: $email_field\n Phone:\n $phone_field\n Company:\n $company_field\n Reseller:\n $reseller_field";						mail($to, $subject, $body);						// run the reseller check function			ResellerCheck();				}				else				{				?>				<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">				<fieldset>				<legend>Purchase SolidCAM Xpress</legend>								<ul>					<li><label for="name">Name <input type="text" name="name" /></label></li>					<li><label for="email">Email <input type="text" name="email" /></label></li>					<li><label for="phone">Phone <input type="text" name="phone" /></label></li>					<li><label for="company">Company <input type="text" name="company" /></label></li>				</ul>								<p>Do you currently have SolidWorks, if yes who is your reseller?</p>				<ul>					<li><label for=""><input type="radio" name="reseller" value="None" /> Don't have SolidWorks</label></li>					<li><label for=""><input type="radio" name="reseller" value="Cad Connect" /> Cad Connect</label></li>					<li><label for=""><input type="radio" name="reseller" value="Cadtek" /> Cadtek</label></li>					<li><label for=""><input type="radio" name="reseller" value="CCSL" /> CCSL</label></li>					<li><label for=""><input type="radio" name="reseller" value="Innova" /> Innova</label></li>					<li><label for=""><input type="radio" name="reseller" value="NT CAD/CAM" /> NT CAD/CAM</label></li>					<li><label for=""><input type="radio" name="reseller" value="Solid Engineer" /> Solid Engineer</label></li>					<li><label for=""><input type="radio" name="reseller" value="Solid Solutions Ireland" /> Solid Solutions Ireland</label></li>					<li><label for=""><input type="radio" name="reseller" value="Solid Solutions Management" /> Solid Solutions Management</label></li>					<li><label for=""><input type="radio" name="reseller" value="TMS Scotland" /> TMS Scotland</label></li>				</ul>								<p><input type="submit" name="continue" value="Continue" /></p>						</fieldset>					</form>				<?php				}				?>				<?php				// Check if user has selected None from the last question then show the message or go to paypal		function ResellerCheck()		{					if($reseller_field == 'None')			{				echo "SolidCAM Xpress requires a valid copy of SolidWorks, we will be in touch shortly to discuss pricing!";			}			else			{							// do paypal stuff			}				}if( /* user is returning from paypal */ ) { echo "Thanks for your purchase, we will be in touch shortly"; }				?>		</body></html>

Edited by driz
Link to post
Share on other sites

Well all of it to be honest. Basically I want to use only one PHP file for the whole thing (with the exception of the PayPal areas off-site). So to break it down, upon a user entering the buy page they should see the form, and then when they hit the continue button and create the postback it should hide the form and then either show the message if they chose None from the radio button list, or send them to PayPal, this is the part I'm most stuck with as I don't want to user to have to re-enter there details on the PayPal website, I've looked at the API but I'm confused about where to go as there are several options. All I want to is get the user to quickly visit the site, either login to PP or enter there credit card details, and then return back to this page.I also want the user to return to this same page after making the purchase, so there needs to be some check for that and show a message saying Thanks.

Link to post
Share on other sites

no one can really to you how to best implement PP into your application. Pick the option that best suites your needs, and then just get down to business on putting something together. When you run into issues we can try and help, or there might be forums or a developers FAQ on the paypal site.

Edited by thescientist
Link to post
Share on other sites

I don't even know where to start with this. I was hoping it was really simple to setup PayPal with a PHP form, I take it that's not the case?Basically all I want is a quick enter your details and then jump to PayPal pay the fee and land back. Can you recommend some code for that kind of functionality.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...