我是 PHP 新手,我正在尝试在 PHP 邮件表单中添加 reCaptcha。
代码类似于:
PHP:
<?php if (isset($_POST['send'])) {
$to = "mymail@gmail.com";
$subject = "subject";
$message = 'Name: ' . $_POST['name'] . "\n";
$message .= 'Email: ' . $_POST['email'] . "\n";
$message .= 'IP: ' . $_SERVER['REMOTE_ADDR'] . "\n";
$message .= 'Message: ' . $_POST['message'];
$success = mail($to, $subject, $message); }?>`
HTML:
<form method="post">
<p>name</p>
<input type="text" name="name" class="contactformimput"/>
<p>email*</p>
<input type="text" name="email" class="contactformimput"/>
<p>number</p>
<input type="text" name="number" class="contactformimput"/>
<p>Messaggio*</p>
<input type="text" name="message" onkeyup="adjust_textarea(this)" class="contactformimput" id="contactformtext">
<div class="g-recaptcha" data-sitekey="__MYPUBBLICKEY__"></div>
<div id="divcontactbutton">
<input type="reset" name="send" value="Resetta" class="button" id="resetmessage"/>
<input type="submit" name="send" value="Invia Messaggio" class="button" id="sendmessage"/>
</div>
</form>