As i am a beginner and i am stucked in a situation. Note: Email sending code present in thankyou.php
My problem is i have to store the Date selected and pass to another page after completion of payment through paypal. I have tried php session but dont where i am lagging.
After success full transaction i am getting all the details in $_POST from the paypal like txn_id, payer_email etc but i am not getting the date which i selected in form.
Please help me to the right direction.
I am working on paypal integration and i have 1 form in which two fields are present (index.php)
- Select date
- No. of tickets
Code index.php :
<?php
@session_start();
$var_value = $_POST['eventdate'];
$_SESSION['eventdate'] = $var_value;
echo $_SESSION['eventdate'];
?>
<form name="_xclick" action="https://www.sandbox.paypal.com/r" method="post">
<table border="0" cellspacing="0" cellpadding="5" id="tbl_paypal_form">
<tr>
<td colspan="2"><div id="ticket_amount">£10 per person</div></td>
</tr>
<tr>
<td>Select Event Date <span class="mandatory">*</span></td>
<td><select name="eventdate" id="eventdate" class="form_field">
<option value="">Select Date</option>
<option value="Sat 14 July 2012">Sat 14 July 2012</option>
<option value="Sun 15 July 2012">Sun 15 July 2012</option>
<option value="Mon 16 July 2012">Mon 16 July 2012</option>
</select></td>
</tr>
<tr>
<td>No. of Tickets <span class="mandatory">*</span></td>
<td><input type="text" name="quantity" id="quantity" class="form_field">
<span style="color:#bbb; font-size:11px; padding-top:5px;">For ex: 4</span>
</td>
</tr>
<tr>
<td colspan="2"><?php
if(!empty($errorMessage))
{
echo("<div id='validation_error'>");
echo("<p class='error_message'>There was an error with your form:</p>\n");
echo("<ul class='error_message'>" . $errorMessage . "</ul>\n");
echo("</div>");
}
?></td>
</tr>
<tr>
<td><img src="images/paypal.gif" /></td>
<td><input type="image" src="images/btn_paypal.gif" border="0" name="formsubmit" value="Submit" onclick="return ValidateForm();" alt="Make payments with PayPal - it's fast, free and secure!">
</td>
</tr>
</table>
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="gala@iskconcoventry.com">
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="item_name" value="Gala Charity Show Tickets">
<input type="hidden" name="amount" value="10">
<input type="hidden" name="return" value="http://www.vyx.com/gala/thankyou.php">
<input type="hidden" name="notify_url" value="http://www.xyx.com/gala/thankyou.php">
<input type="hidden" name="cbt" value="Return to The Store">
<!--<input type="hidden" name="eventdate" value="<?php echo $_POST['eventdate'];?>">-->
</form>
Code: thankyou.php
<?php
session_start();
$ticketdate = $_SESSION['eventdate'];
//echo $_SESSION['eventdate'];
echo $ticketdate;
?>
<pre style="background:#fff;">
<?php print_r($_POST);?>
</pre>
<?php
if($_POST['txn_id'] != "")
{
$mail_subject='Ticket Booked for Gala Charity event';
$mail_body.= 'Hello Dear, <br><br>';
$mail_body.= 'Below are the ticket booking details for Gala Charity event. <br><br>';
$mail_body.= '<b>Booking Date : </b>'. $ticketdate .'<br><br>';
//$mail_body.= '<b>Booking Date : </b>'.trim($_POST['eventdate']).'<br><br>';
$mail_body.= '<b>Number of tickets buyed : </b>'.trim($_POST['quantity']).'<br><br>';
$mail_body.= '<b>Transaction ID : </b>'.trim($_POST['txn_id']).'<br><br>';
$mail_body.= '<b>First Name : </b>'.trim($_POST['first_name']).'<br><br>';
$mail_body.= '<b>Last Name : </b>'.trim($_POST['last_name']).'<br><br>';
$mail_body.= '<b>Payers Email : </b>'.trim($_POST['payer_email']).'<br><br>';
$mail_body.= '<b>Payment Date : </b>'.trim($_POST['payment_date']).'<br><br>';
$mail_body.= '<b>Address Name : </b>'.trim($_POST['address_name']).'<br><br>';
$mail_body.= '<b>Street : </b>'.trim($_POST['address_street']).'<br><br>';
$mail_body.= '<b>Zip : </b>'.trim($_POST['address_zip']).'<br><br>';
$mail_body.= '<b>State : </b>'.trim($_POST['address_state']).'<br><br>';
$mail_body.= '<b>Country Code : </b>'.trim($_POST['address_country_code']).'<br><br>';
$mail_body.= '<b>Item Name : </b>'.trim($_POST['item_name']).'<br><br>';
$mail_body.= '<b>Total Amount Paid : </b>'.trim($_POST['mc_currency']).' '.trim($_POST['mc_gross']).'<br><br>';
$mail_from=$_POST['payer_email'];
$mail_to = "myname@example.com";
//$mail_reply_to = $mail_from;
$mail_headers = "Content-Type: text/html; charset=iso-8859-1\r\nFrom: $mail_from\r\nReply-to: $mail_reply_to\r\n";
@mail($mail_to, $mail_subject, $mail_body, $mail_headers);
}
?>
You should use paypal’s custom data field to send and receive additional values on payments. Simply add another input to your form
If you need to send two or more values you can join them with a separator like
|then process them when you get them back from paypal.EDIT
Change your form to
Add a little javascript to your page before the closing
</body>tagOn the server side just simply explode the value you get