我有以下代码,允许此人选择捐赠金额并下载文件。此刻,这允许该人输入0并下载。我想最低0.99。我怎么能强制要求捐款,否则不下载。感谢您的帮助。
<?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'].'&business=mypaypalemail@here.tld&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/');
}
}
?>
答案 0 :(得分:0)
查看示例:
if(!empty($_POST['submit'])) {
if($_POST['donate_amount'] >= 0.99) {
// Redirect to PayPal
} else {
exit('Please donate at least $.99');
}
}
对于谷歌分析,我不能回答你,抱歉。