联系人表单在添加实现SSL后停止工作,它';s基于PHP,在添加https之前工作正常
我网站上的联系人表单在添加实现SSL后停止工作,它是基于PHP的,在5年前它只是http时工作良好 现在,当表单填写正确时,会显示消息*“抱歉!很遗憾,您的消息无法发送。您填写的表单显示在下面。请确保每个字段都已完成,并请解决下面列出的任何问题:”继续出现 这可能是一个简单的问题,但我不懂PHP,并且在一个教程中发现了这一点——如果有人指出这个问题以及如何解决它,这将非常有帮助 如果需要,我可以提供更多细节 谢谢联系人表单在添加实现SSL后停止工作,它';s基于PHP,在添加https之前工作正常,php,html,ssl,https,contact-form,Php,Html,Ssl,Https,Contact Form,我网站上的联系人表单在添加实现SSL后停止工作,它是基于PHP的,在5年前它只是http时工作良好 现在,当表单填写正确时,会显示消息*“抱歉!很遗憾,您的消息无法发送。您填写的表单显示在下面。请确保每个字段都已完成,并请解决下面列出的任何问题:”继续出现 这可能是一个简单的问题,但我不懂PHP,并且在一个教程中发现了这一点——如果有人指出这个问题以及如何解决它,这将非常有帮助 如果需要,我可以提供更多细节 谢谢 <?php // Information to be modified
<?php
// Information to be modified
$your_email = "mail@website.com"; // email address to which the form data will be sent
$subject = "Visitor Message from Website"; // subject of the email that is sent
$thanks_page = "thankyou.htm"; // path to the thank you page following successful form submission
$contact_page = "../contact.htm"; // path to the HTML contact page where the form appears
// Nothing needs to be modified below this line
if (!isset($_POST['submit'])) {
header( "Location: $contact_page" );
}
if (isset($_POST["submit"])) {
$nam = $_POST["name"];
$ema = trim($_POST["email"]);
$com = $_POST["comments"];
$spa = $_POST["spam"];
if (get_magic_quotes_gpc()) {
$nam = stripslashes($nam);
$ema = stripslashes($ema);
$com = stripslashes($com);
}
$error_msg=array();
if (empty($nam) || !preg_match("~^[a-z\-'\s]{1,60}$~i", $nam)) {
$error_msg[] = "The name field must contain only letters, spaces, dashes ( - ) and single quotes ( ' )";
}
if (empty($ema) || !filter_var($ema, FILTER_VALIDATE_EMAIL)) {
$error_msg[] = "Your email must have a valid format, such as name@mailhost.com";
}
$limit = 1000;
if (empty($com) || !preg_match("/^[0-9A-Za-z\/-\s'\(\)!\?\.,]+$/", $com) || (strlen($com) > $limit)) {
$error_msg[] = "The Comments field must contain only letters, digits, spaces and basic punctuation ( ' - , . ), and has a limit of 1000 characters";
}
if (!empty($spa) && !($spa == "4" || $spa == "four")) {
echo "You failed the spam test!";
exit ();
}
// Assuming there's an error, refresh the page with error list and repeat the form
if ($error_msg) {
echo '<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
<style>
body {background: #f7f7f7; font: 100%/1.375 georgia, serif;padding: 20px 40px;}
form div {margin-bottom: 10px;}
.content {width: 40%; margin: 0 auto;}
h1 {margin: 0 0 20px 0; font-size: 175%; font-family: calibri, arial, sans-serif;}
label {margin-bottom: 2px;}
input[type="text"], input[type="email"], textarea {font-size: 0.75em; width: 98%; font-family: arial; border: 1px solid #ebebeb; padding: 4px; display: block;}
input[type="radio"] {margin: 0 5px 0 0;}
textarea {overflow: auto;}
.hide {display: none;}
.err {color: red; font-size: 0.875em; margin: 1em 0; padding: 0 2em;}
</style>
</head>
<body>
<div class="content">
<h1>Sorry!</h1>
<p>Unfortunately, your message could not be sent. The form as you filled it out is displayed below. Make sure each field completed, and please also address any issues listed below:</p>
<ul class="err">';
foreach ($error_msg as $err) {
echo '<li>'.$err.'</li>';
}
echo '</ul>
<form method="post" action="', $_SERVER['PHP_SELF'], '">
<div>
<label for="name">Name</label>
<input name="name" type="text" size="40" maxlength="60" id="name" value="'; if (isset($_POST["name"])) {echo $nam;}; echo '">
</div>
<div>
<label for="email">Email Address</label>
<input name="email" type="email" size="40" maxlength="60" id="email" value="'; if (isset($_POST["email"])) {echo $ema;}; echo '">
</div>
<div>
<label for="comm">Comments</label>
<textarea name="comments" rows="10" cols="50" id="comm">'; if (isset($_POST["comments"])) {echo $com;}; echo '</textarea>
</div>
<div class="hide">
<label for="spam">What is two plus two?</label>
<input name="spam" type="text" size="4" id="spam">
</div>
<div>
<input type="submit" name="submit" value="Send">
</div>
</form>
</body>
</html>';
exit();
}
$email_body =
"Name of sender: $nam\n\n" .
"Email of sender: $ema\n\n" .
"COMMENTS:\n\n" .
"$com" ;
// Assuming there's no error, send the email and redirect to Thank You page
if (isset($_REQUEST['comments']) && !$error_msg) {
mail ($your_email, $subject, $email_body, "From: $nam <$ema>" . "\r\n" . "Reply-To: $nam <$ema>");
header ("Location: $thanks_page");
exit();
}
}
您能与我共享该表单上载位置的链接吗?请尝试
而不是
。(连接时用点代替逗号)将操作替换为“https://”$_服务器['SERVER_NAME']$_服务器['REQUEST_URI'],然后重试again@mbesson谢谢我会尝试一下并让你知道。@穆纳瓦,谢谢。你的意思是你能帮我吗。解释一下more@saicode看见连接意味着“将两个(或更多)字符串放在一起,因此它只是一个字符串。php中的连接运算符是点。例如:“hello”。“.world”
将导致“hello world”
。但是“hello”、“,”world“
(注意点的逗号)在这种情况下是一个语法错误。