问题描述
问题:表单未发送到电子邮件,标题位置有效(我认为),但不再显示验证码验证消息。
我试过我的 gmail、学校电子邮件和临时电子邮件,但没有任何效果。它曾经发送过,但从那以后我改变了很多以合并错误/成功消息,但不知道出了什么问题。我错过了什么吗?提前致谢!
形式:
<form action="formvalidation.PHP" method="post">
<div>
<label>first name</label>
<input type="text" name="name" for="name" minlength="3" maxlength="20" pattern="[A-Za-z]+" class="form-control" value ="<?PHP echo htmlspecialchars ($name) ?>" required>
</div>
<div>
<label>email</label>
<input type="email" name="email" minlength="3" maxlength="30" class="form-control" value ="<?PHP echo htmlspecialchars ($email) ?>" required>
</div>
<div class="iamnoTarobot">
<div class="g-recaptcha" data-sitekey="secret_key_here"></div>
</div>
<button type="submit" name="send" class="form-button btn">1,2,3... LET'S GO!</button>
<?PHP if (isset($captcha_validation)) { ?>
<p class="validation-message"><?PHP echo $captcha_validation ?></p>
<?PHP } ?>
</form>
formvalidation.PHP:
<?PHP
if (isset($_POST['send'])) {
$userName = $_POST['name'];
$userEmail = $_POST['email'];
$to = "testform@maildrop.cc";
$subject = "New Form Submission";
$body = $userName.' wants to kNow when company_name will be launched! Be sure to email them at '.$userEmail.'.';
#$headers = 'From:' .$email;
$secretKey = "site_key_here";
$responseKey = $_POST['g-recaptcha-response'];
$UserIP = $_SERVER['REMOTE_ADDR'];
$url = "https://www.google.com/recaptcha/api/siteverify?secret=$secretKey&response=$responseKey&remoteip=$UserIP";
$response = file_get_contents($url);
$response = json_decode($response);
if ($response->success)
{
mail($to,$subject,$body);
#header("Location: index.PHP?mailsent");
$captcha_validation = 'Message successfully sent!';
$name = '';
$email = '';
include('index.PHP');
}
else {
#header("Location: index.PHP?invalidcaptcha");
$captcha_validation = 'Invalid captcha. Message not sent.';
include('index.PHP');
}
}
?>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)