我看到了一些类似的问题,但他们没有得到回答,或者他们不是我想要的。
我的网页上有一个简短的表格。当按下“提交”按钮时,表单上的内容将作为电子邮件发送。现在我想添加将用户重定向到贝宝页面的功能,他们可以支付管理费。
有没有办法在表单的“提交”按钮中添加一些代码,以便将客户重定向到贝宝结账(就像他们按下“立即购买”一样),或者,有没有一种方法可以自定义“但它现在'按钮也将具有提交表单的功能?
<?php
session_start();
/* Set the variables below */
$contact_us = "contact-form";
$website_url = 'http://www.yourwebsite.com/';
$error_page_url = $website_url . 'error.html';
$paypal_page_url = $website_url . 'paypalpageurl.html';
$dummy_email = 'no-reply@yourwebsite.com';
$receiver_email_id = 'me@yourwebsite.com';
/** WARNING !! Dont make changes below ***/
if(!empty($_REQUEST['uri'])){
$uri=$_REQUEST['uri'];
}else{
$uri='';
}
switch($uri){
case $contact_us:
contact();
break;
default:
?><meta HTTP-EQUIV="REFRESH" content="0; url=<?php echo $website_url; ?>"><?php
}
function contact($request = "Contact Form"){
global $error_page_url, $paypal_page_url, $dummy_email, $receiver_email_id,$website_url;
$subject = "[yourwebsite.com] - Contact Form";
$email = htmlentities($_REQUEST['email']);
$name = htmlentities($_REQUEST['name']);
$phone = htmlentities($_REQUEST['phone']);
$comment = htmlentities($_REQUEST['comment']);
$filter = htmlentities($_REQUEST['filter']);
$headers = "From:" . $dummy_email;
$headers1 = "From:" . 'no-reply@yourwebsite.com';
$formatted_message = "Request : " . $request . "\n" . "\n" .
"Sender Name : " . $name . "(" . $email . ")" . "\n" . "\n" .
"Email : " . $email . "\n" . "\n" .
"Phone : " . $phone . "\n" . "\n" .
"Comment : " . "\n" . $comment . "\n" . "\n";
$formatted_message_client = "Hi " . $name . ","."\n" . "\n" .
"Thanks for contacting us. We will get back to you soon." . "\n" . "\n" .
"Regards," . "\n" .
"yourwebsite.com Team";
if($_POST['check'] != $_SESSION['check']) {
session_destroy();
?><meta HTTP-EQUIV="REFRESH" content="0; url=<?php echo $error_page_url; ?>"><?php
}
else {
session_destroy();
if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
?><meta HTTP-EQUIV="REFRESH" content="0; url=<?php echo $error_page_url; ?>"><?php
}
else {
if($name == '' or $email == '' or $phone == '' or $filter != ''){
?><meta HTTP-EQUIV="REFRESH" content="0; url=<?php echo $error_page_url; ?>"><?php
}else{
if( mail($receiver_email_id, $subject, $formatted_message, $headers1) &&
mail($email, $subject, $formatted_message_client, $headers)){
//session_destroy();
?><meta HTTP-EQUIV="REFRESH" content="0; url=<?php echo $paypal_page_url; ?>"><?php
}else{
?><meta HTTP-EQUIV="REFRESH" content="0; url=<?php echo $error_page_url; ?>"><?php
}
}
}
}
}
?>
不,表单提交是通过电子邮件或通过 HTTP。
您可以尝试使用 JavaScript 伪造某些东西,但这必然会以奇怪和有趣的方式破坏,因此正确的方法是处理来自 CGI 的表单提交并返回重定向状态代码。