I am looking to create a donate and Dowload script that allows you to put in your own money amount and then it automatically downloads and takes you to paypal. 0 needs to be an option amount also. Here is an example: http://www.losttype.com/font/?name=liberator
I have created a PayPal donate script and edited to add an input amount, but can anyone suggest a way to automatically start the download and allow 0 as an amount?
Maybe I should start again, I have the following code that allows the user to donate with paypal. This has an input amount, and redirects the user to paypal in a new window. What would be the best way to on submit to start the download? even if the person puts in zero, and while they can donate in another window. Code:
<div class="donate">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
<input type="hidden" name="cmd" value="_donations">
<input type="hidden" name="business" value="myemail">
<input type="hidden" name="lc" value="GB">
<input type="hidden" name="item_name" value="info">
<table> <tr><td>Enter your Amount:</td></tr><tr><td><input type="text" name="amount" value=""></td></tr> </table>
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="cn" value="Add special instructions to the seller">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_LG.gif:NonHosted">
<input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_donate_LG.gif" border="0" name="submit">
<img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>
Easy enough really. Detect whether an amount has been chosen, and if it has, redirect to PayPal.
If it hasn't, redirect directly to the file.
Below is a very basic, unchecked example:
<?php
echo "<p>Donate fixed amount to CharityName</p>
<form method='POST' action=''>
<select name='currency_code'>
<option value='EUR'>EUR</option>
<option value='GBP'>GBP</option>
<option value='USD'>USD</option>
<input type='text' name='donate_amount' value='0'>
<input type='submit' name='submit' value='Donate'></form>";
if(!empty($_POST['submit'])) {
// Form has been submitted
if($_POST['donate_amount'] > 0) {
// Redirect to PayPal
header('Location: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&item_name=Donation for XXX&amount='.$_POST['donate_amount'].'¤cy_code='.$_POST['currency_code'].'&[email protected]&cbt=Download the file&return=http://link-to-the-file&cancel_return=http://back-to-my-website');
}
else {
// No donation amount entered - proceed to file directly
header('Location: http://link-to-the-file/');
}
}
?>