Linked Questions

Popular Questions

Trying to add captcha V3 to my contact page. Sometimes it works some times it runs & runs then generates a sever error. Want to be sure it's not the code. Works perfectly when the captcha code is removed. I believe it is go daddy's severs being very slow ? I believe the slow down & error are happening when $recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify'; is reached.

<?php   
$firstName = $_POST['first_name'];
$lastName = $_POST['last_name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$eventDate = $_POST['event_date'];
$eventType = $_POST['event_type'];
$eventDJ = $_POST['DJ'];
$eventHypnosis = $_POST['Hypno'];
$eventDJ_Hypnosis = $_POST['DJ_Hypno'];
$additionalInfo = $_POST['aditional_info'];         

if (isset($_POST['submit_button'])) {
$recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify';
$recaptcha_secret = 'Key goes here';
$recaptcha_response = $_POST['recaptcha_response'];
$recaptcha = file_get_contents($recaptcha_url . '?secret=' . $recaptcha_secret . '&response=' . $recaptcha_response);
$recaptcha = json_decode($recaptcha);
if ($recaptcha->score >= 0.5) {        
$emailTitle = 'Beyond 2000 Entertainment Online Form';
$emailAddress = '[email protected]';     
$firstName = $_POST['first_name'];
$lastName = $_POST['last_name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$eventDate = $_POST['event_date'];
$eventType = $_POST['event_type'];
$eventDJ = $_POST['DJ'];
$eventHypnosis = $_POST['Hypno'];
$eventDJ_Hypnosis = $_POST['DJ_Hypno'];
$additionalInfo = $_POST['aditional_info'];       
$body = <<<EOD
<br><hr><br>
First Name: $firstName <br/><br/>
Last Name: $lastName <br/><br/>
Phone Number: $phone <br/><br/>
Email Address: $email <br/><br/>
Event Date: $eventDate <br/><br/>
Event Type: $eventType <br/><br/>
Service Required:  $eventDJ $eventHypnosis $eventDJ_Hypnosis <br/><br/>
Additional Info: $additionalInfo <br/><br/>
EOD;

 $headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";  
ini_set('SMTP', "Relay-Hosting.secureserver.net");  
$success = mail("$emailAddress", "$emailTitle", "$body", "$headers");   
$firstName = "";
$lastName = "";
$phone = "";
$email = "";
$eventDate = "";
$eventType = "";
$eventDJ = "";
$eventHypnosis = "";
$eventDJ_Hypnosis = "";
$additionalInfo = "";   

echo '<script type="text/javascript">',
'modalFunction();',
'</script>';    
}   
else {        
}
} ?>

Related Questions