去年在一个网站刊登联络表格了。到今年4月19日为止一切正常。我没有更改任何版本。我的php详细信息是
现在我遇到此错误
PHP注意:未定义的索引:第14行的commit-form.php中的g-recaptcha-response
PHP致命错误:在第26行,调用submit-form.php中未定义的函数json_decode()
{main} 在第19行上的Submit-form.php中抛出 PHP致命错误:未捕获错误:在commit-form.php:19中调用未定义的函数curl_init()
submit-form.php
<?php
if (isset($_POST['submit'])) {
if ($_POST['name'] != null && $_POST['email'] != null && $_POST['subject']) {
} else {
$error = "Complete all the fields";
}
if (isset($error)) {
echo $error;
} else {
$g_resp = $_POST['g-recaptcha-response'];
$secret = "************"; // Secret key provided by google
$postdata = "secret=".$secret."&response=".$g_resp; // we will post the data to the google
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch); // response from the google
$out = json_decode($server_output);
curl_close($ch);
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$to = '******';
$headers = 'From: '.$name."\r\n" .
'Reply-To: '.$email."\r\n" .
'X-Mailer: PHP/' . phpversion();
$subject = $subject;
$body = 'You have a new message from the contact form'."\n\n";
$body .= 'Name: '.$name."\n";
$body .= 'Email: '.$email."\n";
$body .= 'Subject: '.$subject."\n";
$body .= 'Message: '."\n".$message."\n";
if ($out->success == 1) {
if (mail($to, $subject, $body, $headers)) {
die('Mr.'.$name.' Thank you for contacting us. We will be in touch with you very soon.');
} else {
die('Message Failed. Pl.Try again');
}
} else {
die('Captcha Failed');
}
}
}
HTML
<!-- Contact Form Block -->
<div class="col-md-12 form-block contact-form-block">
<!-- Form Block Container -->
<div class="form-block-container">
<form method="post" id="contactform" action="php/submit-form.php">
<!-- Name -->
<div class="col-md-4">
<div class="form-group"><input type="text" class="form-control contact-name" name="name">
<label>Name*</label>
</div>
</div><!-- /End Name -->
<!-- Email Address -->
<div class="col-md-4">
<div class="form-group">
<input type="text" class="form-control contact-email" name="email">
<label>Email address*</label>
</div>
</div><!-- /End Email Address -->
<!-- Subject -->
<div class="col-md-4">
<div class="form-group">
<input type="text" class="form-control contact-subject" name="subject">
<label>Subject*</label>
</div>
</div><!-- /End Subject -->
<!-- Message -->
<div class="col-md-12">
<div class="form-group">
<textarea class="form-control contact-message" name="message"></textarea>
<label>Message*</label>
</div>
</div><!-- /End Message -->
<!-- Recaptcha -->
<div class="col-md-12">
<div class="form-group">
<div class="g-recaptcha" data-sitekey="******"></div>
</div>
</div><!-- /End Recaptcha -->
<!-- Submit Button -->
<div class="col-md-12">
<div class="form-group">
<input type="submit" name="submit" id="submit" class="btn btn-gfort wave-effect">SEND MESSAGE</input>
</div>
<div id="result"></div>
</div><!-- /End Submit Button -->
</form>
</div><!-- /End Form Block Container -->
Pl。帮我解决这个问题
预先感谢