2017-03-07 63 views
0

我现在在ASP中工作。我喜欢用PHP编码,但我的公司在他们的网站上使用ASP。在我的公司网站上有与我们的CRM连接的表格,关于许多发布的垃圾邮件,我们需要将Google recaptcha发布到表单中。Google recaptcha ASP(Classic)上的一页

以下是我为我开发的很多网站使用的recaptcha PHP代码,可以在ASP上有这样的代码一样的方法吗?我只需要只有一页。

<?php 
if(isset($_POST['submit'])): 
if(isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha- response'])): 
    //your site secret key 
    $secret = '6Le5ohYUAAAAAAWeXQ4TnEMsOrW7wSw4WcNUVyS7'; 
    //get verify response data 
    $verifyResponse = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secret.'&response='.$_POST['g-recaptcha-response']); 
    $responseData = json_decode($verifyResponse); 

    if($responseData->success):   
     $succMsg = 'Your contact request have submitted successfully.'; 
    else: 
     $errMsg = 'Robot verification failed, please try again.'; 
    endif; 
    else: 
     $errMsg = 'Please click on the reCAPTCHA box.'; 
    endif; 
else: 
$errMsg = ''; 
$succMsg = ''; 
endif; 
?> 

<html> 
<head> 
    <title>Google reCAPTCHA</title> 
    <script src="https://www.google.com/recaptcha/api.js" async defer> </script> 
</head> 
<body> 
<div class="registration"> 
    <h2>Contact Form</h2> 
    <?php if(!empty($errMsg)): ?><div class="errMsg"><?php echo $errMsg; ?></div><?php endif; ?> 
    <?php if(!empty($succMsg)): ?><div class="succMsg"><?php echo $succMsg; ?></div><?php endif; ?> 
    <div class="form-info"> 
     <form action="" method="POST"> 
      <input type="text" class="text" value="<?php echo !empty($name)?$name:''; ?>" placeholder="Your full name" name="name" > 
      <input type="text" class="text" value="<?php echo !empty($email)?$email:''; ?>" placeholder="Email adress" name="email" > 
      <input type="text" placeholder="Message..." name="message"><?php echo !empty($message)?$message:''; ?></textarea> 
      <div class="g-recaptcha" data-sitekey="6Le5ohYUAAAAAPDz2w2tDQ-3AgYwgEQmkOhnwYhO"></div> 
      <input type="submit" name="submit" value="SUBMIT"> 
     </form> 
    </div>   
    <div class="clear"> </div> 
</div> 
</body> 
</html> 
+1

我投票结束这个问题作为题外话,因为StackOverflow不是一个免费的代码写作服务。 – Constantin

回答