File: //home/awaldron/_domains/thecasinocrusher.com/application/controllers/Contact.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Contact extends CI_Controller {
public function index()
{
// IF FORM SUBMITTED
$post = $this->input->post();
$formsent = false;
$formsubmitted = false;
if (!empty($post['email']) && empty($post['comments'])) {
$this->email->from($post['email'], $post['name']);
$this->email->to('setdice@aol.com, thecasinocrusher@gmail.com');
$this->email->bcc('alan@waldroninteractive.com');
$msg = "Name: ".$post['name']."\n";
$msg .= "Email: ".$post['email']."\n";
$msg .= "Phone: ".$post['phone']."\n\n";
$msg .= "Message: "."\n".$post['message'];
$this->email->subject('CasinoCrusher Contact Us Message');
$this->email->message($msg);
$this->email->send();
$formsent = true;
$formsubmitted = true;
} else if (!empty($post['comments'])) {
$formsent = true;
$formsubmitted = true;
} else if (!empty($post['email'])) {
$formsent = false;
$formsubmitted = true;
}
$data = array(
'pageTitle' => 'Contact Us',
'pageDesc' => 'Contact the Casino Crusher to learn how to beat the casino in Craps or Blackjack.',
'tabOn' => 'contact'
);
$data['formsent'] = $formsent;
$data['formsubmitted'] = $formsubmitted;
$this->load->view('_header', $data);
$this->load->view('contact', $data);
$this->load->view('_footer', $data);
}
private function checkCaptcha( $captcha ){
if (!empty($captcha)){
$postdata = http_build_query(
array(
'secret' => 'your-secret-key',
'response' => $captcha,
'remoteip' => $_SERVER['REMOTE_ADDR']
)
);
$options = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($options);
$result = json_decode(file_get_contents('https://www.google.com/recaptcha/api/siteverify', false, $context));
return $result->success;
} else {
return false;
}
}
}