Php 以表格形式重述

Php 以表格形式重述,php,recaptcha,Php,Recaptcha,我的表单与以下URL几乎相同: 网址: 但在将PHP代码添加到我的网站(www.obzservices.com)后,我的网站只是向我显示预加载程序图标,即我的网站没有加载。我以前编辑过我的PHP代码,添加了我的站点密钥,添加了$name、$title、$location等等,但没有任何帮助。以下是我的PHP代码: <?php $name = $_POST['name']; $email = $_POST['email']; $title = $_POST['tit

我的表单与以下URL几乎相同:

网址:

但在将PHP代码添加到我的网站(www.obzservices.com)后,我的网站只是向我显示预加载程序图标,即我的网站没有加载。我以前编辑过我的PHP代码,添加了我的站点密钥,添加了$name、$title、$location等等,但没有任何帮助。以下是我的PHP代码:

<?php

    $name = $_POST['name'];
    $email = $_POST['email'];
    $title = $_POST['title'];
    $location = $_POST['location'];
    $industry = $_POST['industry'];
    $quantity = $_POST['quantity'];
    $message = $_POST['message'];
    $from = 'From: QuoteForm';
    $to = 'obaid@obzservices.com';
    $subject = 'Quote Request';

    $body = "From: $name\n E-Mail: $email\n Title: $title\n Location: $location\n Industry: $industry\n Quantity: $quantity\n Message:\n $message";


    if ($_POST['submit']) {
        if ($email != '') {
            if(mail ($to, $subject, $body, $from)) {
                echo '<p>Your message has been sent!</p>';

            } else {
                echo '<p>Something went wrong, go back and try again!</p>';
            }
        }

    }?>

添加以下simpleScript

 <script src='https://www.google.com/recaptcha/api.js'></script>
 <script>

   function get_action(form) 
 {
 var v = grecaptcha.getResponse();
  if(v.length == 0)
   {
document.getElementById('captcha').innerHTML="You can't leave Captcha Code empty";
return false;
 }
  else
  {
document.getElementById('captcha').innerHTML="Captcha completed";
return true; 
}
    }

</script>

函数get_动作(表单)
{
var v=grecaptcha.getResponse();
如果(v.length==0)
{
document.getElementById('captcha').innerHTML=“您不能将captcha代码保留为空”;
返回false;
}
其他的
{
document.getElementById('captcha').innerHTML=“captcha已完成”;
返回true;
}
}
并在“提交”按钮之前添加此HTML:

 <span id="captcha" style="color:red" /></span> 
<div class="g-recaptcha" id="rcaptcha"  data-sitekey="site key"></div>

将此添加到您的表单中

onSubmit="return get_action()" such  As below
  <form action="" method="post" onSubmit="return get_action()">  
onSubmit=“return get_action()”如下所示

我应用了这一点,但当我尝试时,即使没有解决验证码,我也能够提交表单。我还更新了我的答案,你在哪里添加了javascript?将此添加到htmlI之上我尝试在两者之前添加javascript。但在这两种情况下都失败了。我已经编辑了上面的PHP代码。请看一看。谢谢请再次核对我的答案。