I have a form that collects data on a persons car (year, color, class, last 4 digits of vin. That same form also has information on the person registering for this event.
When the user clicks the paypal buy now button it should send an email to the person who is accepting the forms as well as redirect the user to paypal so the user can pay the registration fee.
You will see a submit button as well as a buy now button. I basically want the functionality of the submit but the redirection to paypal like the buy now button. Also not sure what the action should be on the form.
<div id="container">
<section id="register">
<form action="mail.php" method="post" accept-charset="utf-8" on>
<h4>Your Jeep</h4>
<div class="form-field">
<fieldset>
<label>Year</label>
<input value="" placeholder="Year" type="text" name="year">
</fieldset>
<fieldset>
<label>Color</label>
<input value="" placeholder="Color" type="text" name="color">
</fieldset>
<fieldset>
<label>Class</label>
<input value="" placeholder="Stock, Modified, Highly Modified" type="text" name="class">
</fieldset>
<!--------------------
<div class="form-field">
<fieldset>
<label>Class</label>
<select class="form-field">
<option value="Select Class">Select Class</option>
<option value="Stock">Stock</option>
<option value="Modified">Modified</option>
<option value="Highly Modified">Highly Modified</option>
</select>
</fieldset>
</div>
------------------------->
<fieldset>
<label>Last 4 digits of VIN</label>
<input value="" placeholder="Last 4 digits of VIN" type="text" name="vin">
</fieldset>
</div>
<h4>You</h4>
<div class="form-field">
<fieldset>
<label>Name</label>
<input value="" placeholder="Name" type="text" name="name">
</fieldset>
</div>
<div class="form-field">
<fieldset>
<label>Address</label>
<input value="" placeholder="Address" type="text" name="address">
</fieldset>
</div>
<div class="form-field">
<fieldset>
<label>City</label>
<input value="" placeholder="City" type="text" name="city">
</fieldset>
</div>
<div class="form-field">
<fieldset>
<label>State</label>
<input value="" placeholder="State" type="text" name="state">
</fieldset>
</div>
<div class="form-field">
<fieldset>
<label>Zip</label>
<input value="" placeholder="Zip" type="text" name="Zip">
</fieldset>
</div>
<div class="form-field">
<fieldset>
<label>Email</label>
<input value="" placeholder="Email" type="text" name="email">
</fieldset>
</div>
<div class="form-button">
<input type="submit" onclick="this.form.submit();"></div>
</form>
<div id="paykim">
<form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="me#mybusiness.com">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="item_name" value="Jeep Registration">
<input type="hidden" name="amount" value="10.00">
<input type="image" src="http://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
<p>Clicking the Submit button will bring you to the official PayPal website where you will be able to send the $10 Registration Fee to </p>
<p id="ekim">Email of person accepting the registrations.</p>
<p id="confirm">You'll recieve a conformation email once your transaction is complete.</p>
</div>
</section>
</div>
http://jsfiddle.net/BsVv5/
I assume you will be store the data in a database. I recommend that first save your form data in the database, Once stored, create a checkout page by querying the database and creates the additional form of paypal. you will require documentation of ipn paypal for sending instant notifications.
https://developer.paypal.com/webapps/developer/docs/classic/products/instant-payment-notification/
Related
guys I have a problem with a PHP page.
I'm trying to make a form to update the record of a DB.
I'm displaying the form with an echo but I have some problems with quotes
<? echo'
<img src="logo.jpg">
<fieldset>
<input name="aspettogen2" type="text" value="<?php echo $aspettogen;?>">
</fieldset>
<fieldset>
<input name="desc" type="text" maxlength="255">
</fieldset>
<fieldset>
<input name="ragsoc" type="text" maxlength="100">
</fieldset>
<fieldset>
<input name="numcivico" type="text" maxlength="20">
</fieldset>
<fieldset>
<input name="validita" type="text">
</fieldset>
<fieldset>
<input name="odierna" type="data">
</fieldset>
<fieldset>
<input name="preavviso" type="text">
</fieldset>
<fieldset>
<input name="scadenza" type="text">
</fieldset>
<fieldset>
<input name="presc" type="text" maxlength="255">
</fieldset>
<fieldset>
<input name="freq" type="number">
</fieldset>
<fieldset>
<input name="datacontr" type="text">
</fieldset>
<fieldset>
<input name="proxcontr" type="text">
</fieldset>
<fieldset>
<input name="note" type="text">
</fieldset>
</form>
</div>
</body>
</html>';
in the first fieldset value="<?php echo $aspettogen;?"> it appears gray because the quote after the echo turn it into a "comment" and i cant print the value..
how can i solve it?
i've tried to do like this Value="'<?php echo $aspettogen;?'"> but i receive the error Parse error: syntax error, unexpected '?' in /var/..... on line 50
You have wrong syntax in that line. I have made the necessary changes.
Code:
<? echo'
<img src="logo.jpg">
<fieldset>
<input name="aspettogen2" placeholder="Aspetto Generale" type="text" value="<?php echo $aspettogen;?>">
</fieldset>
<fieldset>
<input name="desc" placeholder="Descrizione" type="text" maxlength="255">
</fieldset>
<fieldset>
<input name="ragsoc" placeholder="Ragione Sociale" type="text" maxlength="100">
</fieldset>
<fieldset>
<input name="numcivico" placeholder="Numero Civico" type="text" maxlength="20">
</fieldset>
<fieldset>
<input name="validita" placeholder="Validita" type="text">
</fieldset>
<fieldset>
<input name="odierna" placeholder="Data" type="data" id="today" readonly >
</fieldset>
<fieldset>
<input name="preavviso" placeholder="Preavviso" type="text">
</fieldset>
<fieldset>
<input name="scadenza" placeholder="Scadenza" type="text">
</fieldset>
<fieldset>
<input name="presc" placeholder="Prescrizioni" type="text" maxlength="255">
</fieldset>
<fieldset>
<input name="freq" placeholder="Frequenza (in giorni)" type="number">
</fieldset>
<fieldset>
<input name="note" placeholder="Note" type="text">
</fieldset>
<fieldset>
<button name="submit" type="submit" id="contact-submit">Inserisci</button>
</fieldset>
</form>
</div>
</body>
</html>';?>
I have 3 forms in an accordion, one for personal details, billing info and delivery info. I want to autofill the form in the delivery info section if the 'yes' radio button is selected when being asked if their billing and delivery info are the same.
I've looked on the web and can't seem to find anything on filling in a form in an accordion or on the same page.
Here is the HTML:
Details
<img class="editcheckoutbtn" src="<?php echo ROOT; ?>/Images/Buttons/rentals_84x25_edit.png">
<div class="inputsection details">
<form id="detailsform">
<label for="firstname">First Name*</label>
<input type="text" name="forename" />
<label for="lastname">Last Name*</label>
<input type="text" name="surname" />
<label for="email">Email*</label>
<input type="email" name="email" />
<label for="contactnumber">Contact Number*</label>
<input type="text" name="contactnumber"/>
<p class="marketingtext">Do you wish to be contacted by Interski with future promotions?</p>
<label>
<input type="radio" name="marketing" value="yes"/>Yes
</label>
<label>
<input type="radio" name="marketing" value="no"/>No
</label>
<div class="confirmdetailsbtn">
<input type="image" src="<?php echo ROOT; ?>/Images/Buttons/rentals_84x25_confirm.png">
</div>
</form>
</div>
<h3>billing address</h3>
<img class="editcheckoutbtn" src="<?php echo ROOT; ?>/Images/Buttons/rentals_84x25_edit.png">
<div class="inputsection billing">
<form id="billingform">
<label for="firstaddress">1st line of Address*</label>
<input type="text" name="firstaddress"/>
<label for="secondaddress">2nd line of Address</label>
<input type="text" name="secondaddress"/>
<label for="town">Town*</label>
<input type="text" name="town" />
<label for="postcode">Postcode*</label>
<input type="text" name="postcode" />
<label for="country">Country*</label>
<select name="country">
<option></option>
</select>
<p class="billingtext">Is your delivery address the same as your billing address?</p>
<label>
<input type="radio" id="deliveryyes" name="deliveryradio" value="yes"/>Yes
</label>
<label>
<input type="radio" id="deliveryno" name="deliveryradio" value="no"/>No
</label>
<div class="confirmbillingbtn">
<input type="image" src="<?php echo ROOT; ?>/Images/Buttons/rentals_84x25_confirm.png">
</div>
</form>
</div>
<h3>Delivery Address</h3>
<img class="editcheckoutbtn" src="<?php echo ROOT; ?>/Images/Buttons/rentals_84x25_edit.png">
<div class="inputsection delivery">
<form id="deliveryform">
<label for="firstaddress">1st line of Address*</label>
<input type="text" name="delfirstaddress" required/>
<label for="secondaddress">2nd line of Address</label>
<input type="text" name="delsecondaddress"/>
<label for="town">Town*</label>
<input type="text" name="deltown" />
<label for="postcode">Postcode*</label>
<input type="text" name="delpostcode" />
<label for="country">Country*</label>
<select name="delcountry">
<option></option>
</select>
<div class="confirmdeliverybtn">
<input type="image" src="<?php echo ROOT; ?>/Images/Buttons/rentals_84x25_confirm.png">
</div>
<div id="confirmbtn">
<input type="image" src="<?php echo ROOT; ?>/Images/Buttons/rentals_200x38_proceed_to_payment.png">
</div>
This is in complete assumption that as you mentioned its accordion,your page is not refreshed.
You can simply add an event listener on your Radio button to access the required fields and then use them to show wherever required.
Also give proper id's to your input fields
You can do it like this;
$("#deliveryyes").on('click',function(){
var firstaddress = $("#firstaddress").val();
...
// Use those values to populate other fields like
$("#delfirstaddress").val(firstaddress );
...
});
This way you can achieve it.
I currently have a form on my Wordpress shop which submits details to Paypal using the "Buy Now" button API. What I would like to do is based on the 'School' my customer selects on the form, I would like to submit the related Paypal e-mail address. I am currently storing the e-mail address related to the school in my database, so all I need to do is a SELECT from my database based on the selected school name.
I'd like to do this by submitting the form to a PHP class which then forwards the information to the Paypal API. My question is, as a PHP newbie, how do I do this? Here's the form code I have... how do I forward these fields to another PHP class which collects the selected dropdown field value and submits to Paypal?
Thanks in advance!!
<?php
class Template {
public function __construct() {
}
public function getForm($project_list, $business){
$require_mark = '<strong style="color:red;">*</strong>';
?>
<div id="payment_booking_main">
<form name="_xclick" id="payment_booking_form" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- <form name="_xclick" id="payment_booking_form" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"> -->
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="hosted_button_id" value="7ACDDDD4URDK2" />
<!-- This is the paypal email that is sent. -->
<input type="hidden" name="business" value="<?php echo $business; ?>" />
<input type="hidden" name="a3" value="1">
<input type="hidden" name="p3" value="1">
<input type="hidden" name="t3" value="D">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" id="payment_booking_return_url" name="return" value="" />
<input type="hidden" id="payment_booking_notify_url" name="notify_url" value="">
<input type="hidden" id="payment_booking_total_amount" name="amount" value="0">
<input type="hidden" id="payment_booking_item_name" name="item_name" value="">
<input type="hidden" id="payment_booking_item_number" name="item_number" value="">
<!-- Where the project name option input is populated on form load -->
<div id="payment_booking_project_selectform">
<div class="payment_booking_line" style="heigth:20px !important;">
<span class="payment_booking_label">Project :</span>
<select id="payment_booking_project" name="payment_booking_project">
<?php
global $wpdb;
$sql = "SELECT * FROM `{$wpdb->prefix}payment_booking_project` WHERE project_status =1";
$project_list = $wpdb->get_results($sql);
foreach($project_list as $project){
echo '<option value="'.$project->id.'" amount="'.number_format($project->project_amount, 2).'" description="'.$project->project_description.'" price="'.$project->project_price.'">'.$project->project_name.'</option>';
}
?>
</select>
<span id="payment_booking_project_description" style="font-size:12px;"></span>
</div>
</div>
<div id="payment_booking_project_list"></div>
<div class="payment_booking_line">
<span class="payment_booking_label">Name <?php echo $require_mark; ?> :</span>
<span class="payment_booking_input"><input type="text" id="payment_booking_name" name="payment_booking_name" class="required" /></span>
</div>
<div class="payment_booking_line">
<span class="payment_booking_label">Address <?php echo $require_mark; ?> :</span>
<span class="payment_booking_input"><textarea id="payment_booking_address" name="payment_booking_address" class="required"></textarea></span>
</div>
<div class="payment_booking_line">
<span class="payment_booking_label">Home Phone Number :</span>
<span class="payment_booking_input"><input type="text" id="payment_booking_phone" name="payment_booking_phone" /></span>
</div>
<div class="payment_booking_line">
<span class="payment_booking_label">Email Address <?php echo $require_mark; ?> :</span>
<span class="payment_booking_input"><input type="text" id="payment_booking_email" name="payment_booking_email" class="required" /></span>
</div>
<div class="payment_booking_line">
<center>
<img id="img_submit" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_buynowCC_LG.gif" alt="PayPal — The safer, easier way to pay online." />
</center>
</div>
</form>
</div>
<?php
}
}
?>
I am making a basic new customer database with mysql and php. I would like when people click on the radio button"different mailing address" for another couple of input fields to appear for the mailing address. Im not quite sure how to handle this with inputs and not variables. Is there a way to do an if statement here is my html form code below
<form method="POST" action="insert.php">
<fieldset>
<legend>New Customer data</legend>
<label>Complete Below</label>
<div class="controls controls-row">
<input class="span4" name="firstname" type="text" placeholder="First name">
<input class="span3" name="lastname" type="text" placeholder="Last Name">
<input class="span3" name="phone" type="text" placeholder="Phone">
</div>
<div class="controls controls-row">
<input class="span4" name="address" type="text" placeholder="Address">
<input class="span2" name="city" type="text" placeholder="City">
<input class="span1" name="state" type="text" placeholder="State">
</div>
<div class="controls controls-row">
<input class="span4" name="zip" type="text" placeholder="Zip Code">
<input class="span2" name="email" type="text" placeholder="Email">
<input class="span2" name="ccemail" type="text" placeholder="cc email">
</div>
<span class="help-block">When is the customers due date monthly</span>
<label class="radio">
<input type="radio" name="duedate" id="optionsRadios1" value="1" checked>
1st of the month</label>
<label class="radio">
<input type="radio" name="duedate" id="optionsRadios2" value="15">
15th of the month
</label>
<span class="help-block">Mailing address</span>
<label class="radio">
<input type="radio" name="mailingaddress" id="optionsRadios3" value="1" checked>
Check if mailing address is the same as the service address
</label>
<label class="radio">
<input type="radio" name="mailingaddress" id="optionsRadios4" value="0">
Check if mailing address is different
</label>
<button type="submit" class="btn btn-primary">Submit</button>
</fieldset>
</form>
Using jQuery, have two inputs that are initially hidden. Once the user checks the box, '$.show()' on those two inputs. Id have a div containing two inputs, and just show or hide the div depending on whether the box is checked or not
you can try this.
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" >
</script>
<script>
$(document).ready(function(){
$("#checkme").on('change',function(){
if($("#checkme").is(":checked")){
$("input#myemail").fadeIn();
}else{
$("input#myemail").fadeOut();
}
});
});
</script>
</head>
<body>
show: <input type="checkbox" id="checkme" /><br />
<input type="text" id="myemail" hidden />
</body>
</html>
i have setup a form than when pressed the image submit button it sends the filled form to the buisness email.
Here is the script i have used for php linked from my html.
<?php
if(isset($_POST['submit'])) {
$emailbody = 'First Name = '.$_POST['Name']."\n"
.'Surname = '.$_POST['SName']."\n"
.'Email = '.$_POST['email']."\n"
.'Contact Number = '.$_POST['tel_no']."\n"
.'Adress Line 1 = '.$_POST['address_line_1']."\n"
.'Adress Line 2 = '.$_POST['address_line_2']."\n"
.'Town/City = '.$_POST['town_city']."\n"
.'County = '.$_POST['county']."\n"
.'Post Code = '.$_POST['Post_code']."\n"
.'Newsletter = '.$_POST['newsletter']."\n"
.'Events = '.$_POST['events']."\n"
mail('My email#gmail.com', 'Order Form', $emailbody);
} else {
header('location: Payment.html');
}
?>
The form on the html has been linked via a action. is there anything wrong with the script?
PS on pressing the image it is then forwarded to paypal payment page.
Cheers
Edit:
Here is the HTML Code:
<form name="form1" method="post" action="PaymentFormmail.php" align="left">
<section>
<h1>Basic Infomation:</h1>
<p>
<label for="SName">First Name:</label>
<input type="text" name="Name" id="Name" style="margin-left:50px;">
</p>
<p>
<label for="SName">Surname:</label>
<input type="text" name="SName" id="SName" style="margin-left:64px;">
</p>
<p>
<label for="email">Email Address</label>
<input type="text" name="email" id="email" style="margin-left:28px;">
</p>
<p>
<label for="tel_no">Contact Number:</label>
<input type="text" name="tel_no" id="tel_no" style="margin-left:14px;">
</p>
</section>
<section>
<h1>Billing Infomation:</h1>
<p>
<label for="address_line_1">Address line 1:*</label>
<input name="address_line_1" type="text" id="address_line_1" align="right" style="margin-left:20px;">
</p>
<p>
<label for="address_line_2">Address Line 2: </label>
<input type="text" name="address_line_2" id="address_line_2"style="margin-left:20px;">
</p>
<p>
<label for="town_city">Town/City:*</label>
<input type="text" name="town_city" id="town_city"style="margin-left:55px;">
</p>
<p>
<label for="county">County:*</label>
<input type="text" name="county" id="county"style="margin-left:73px;">
</p>
<p>
<label for="Post_code">Post Code:*</label>
<input type="text" name="Post_code" id="Post_code"style="margin-left:46px;">
</p>
<h1>News and Events:</h1>
<p>
<input name="newsletter" type="checkbox" id="newsletter" value="Yes">
<label for="newsletter">I wish to receive the monthly newsletter from Monster Computers UK</label>
</p>
<p>
<input name="events" type="checkbox" id="events" value="Yes">
<label for="events">I wish to receive any infomation about upcomming events</label>
</p>
</section>
</form>
<p>By Clicking Pay now you agree to the Terms of Service</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="monstercomputeruk#gmail.com">
<input type="hidden" name="lc" value="GB">
<input type="hidden" name="item_name" id="byoName" value="0">
<input type="hidden" name="amount" id="finalpaypal">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest">
<input name="submit" type="image" onClick="MM_validateForm('Name','','R','SName','','R','email','','R','address_line_1','','R','town_city','','R','county','','R','Post_code','','R');return document.MM_returnValue" src="images/buttons/Pay Now.png" alt="PayPal — The safer, easier way to pay online." border="0">
<img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>
Try changing
if(isset($_POST['submit']))
to
if(isset($_POST['SName']))
I think $_POST['submit'] doesn't work..
If this also fails then it means that the information isn't sent to your script.
In this case show us your html for the form used in the script.
EDIT
Using if(isset($_POST['submit'])) to not display echo when script is open is not working
EDIT AFTER HTML
in your javascript function called MM_validateForm
send your information using jquery POST to your mail script and remove the if clause checking if isset.
$.post("test.php", { name: "John", time: "2pm" } );
http://api.jquery.com/jQuery.post/
See examples section.