【发布时间】:2021-01-04 14:57:19
【问题描述】:
我在这里尝试做的是要求客户在一个表格中写下他的姓名、地址、邮政编码等,这会将他带到贝宝付款(立即付款按钮),并且还会发送我插入的输入值。
我要求这些东西的原因是因为这项工作意味着清洁窗户,留下一张写有价格的纸,客户去网站并通过贝宝付款,但要确认他的付款,我需要地址。 paypal和email之间的付款确认主要是发送时间和金额,bc paypal不提供任何客户信息。
我的想法是只在付款完成后发送电子邮件,但它在贝宝上,所以我对此一无所知。
我尝试过使用调用两个动作的脚本,但只发生一个动作。我还尝试将 inputs 放在另一个表单上,但按钮使用脚本调用它们,但仍然只有一个执行操作。
我真的需要这个,它是网站的必需品,我就是做不到,我一直在努力寻找任何有用的东西,我确实发现了类似的问题,但我的问题仍然存在。
HTML:
<form target="_blank" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top" >
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="example@hotmail.com">
<!-- Payment Info -->
<input type="hidden" name="item_name" value="Window Cleaning">
<input type="hidden" name="item_number" value="1">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="tax" value="0.50">
<input name="shipping" type="hidden" value="0.00">
<input name="cancel_return" type="hidden" value="http://localhost/Window_Cleaner/menu/payment_confirmation/cancel.html" >
<!-- Client Data -->
<!-- Set variables that override the address stored with PayPal. -->
<div id="divContainer" style="width: 90%;">
<input name="amount" placeholder="Amount">.50£<br>
<input name="first_name" placeholder="First Name" required>
<input name="last_name" placeholder="Last Name" required><br>
<input style="width: 72%; padding: 10px; margin: 5px;" name="address" placeholder="Address" required><br>
<input name="city" placeholder="City" >
<input name="zip" placeholder="Post Code" required><br>
</div>
<br>
<!-- Button Pay Now -->
<button class="paypalpaybutton" name="submit" >
<input style="width: 70px; height: 18px;" type="image" src="http://localhost/Window_Cleaner/pictures/paypal/pp.png" border="0" alt="PayPal – The safer, easier way to pay online!">
</button>
</form >
PHP:
<?php //For paypal Form
if(isset($_POST['submit'])) {
$amount=$_POST["amount"];
$fname=$_POST["first_name"];
$lname=$_POST["last_name"];
$address=$_POST["address"];
$city=$_POST["city"];
$zip=$_POST["zip"];
////////////////////////////////////////////////////////////////////////////////////////////////////
function sanitize_my_email($field) {
$field = filter_var($field, FILTER_SANITIZE_EMAIL);
if (filter_var($field, FILTER_VALIDATE_EMAIL)) {
return true;
} else {
return false;
}
}
$to_email = 'example@gmail.com';
$subject = 'Payment of Marco\'s Window Cleaning Service';
//$message;
$headers = "From: $fname $lname <example@hotmail.com>";//this email is actually my own, as i dont ask for a email, not needed
$message = "I'm your client, $fname $lname and I have paid $amount £ for the Window Cleaning service you have provided me with.
Address: $address
City: $city
Post Code: $zip
**Always confirm the payment and its value on your own paypal account.
Regards, Marco's Window Cleaning";
mail($to_email, $subject, $message, $headers);
////////////////////////////////////////////////////////////////////////////////////////////////////
}
?>
CSS:
#divContainer input{
width: 35%;
padding: 10px;
margin: 6px;
border-radius: 25px;
border: 0,1px solid black;
font-size: 16px;
}
#divContainer input:active{
border-radius: 15px;
}
#divContainer input:focus{
border-radius: 15px;
}
.paypalpaybutton{
cursor: pointer;
background-color: #3671b0;
border-radius: 35px;
width: 370px;
height: 40px;
border: none;
}
.paypalpaybutton:hover{
background-color: #3c7dc3;
}
【问题讨论】:
-
fwiw.. 你的按钮中有两次名称标签。