<?php
echo "<pre>"; print_r($_POST)  ;  echo "</pre>".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; 
//error_reporting(0);
//$sender_name = stripslashes($_POST["sender_name"]);
	$sender_email = stripslashes($_POST["email"]);
	$sender_message = stripslashes($_POST["form_result"]);
	$response = $_POST["g-recaptcha-response"];
	$url = 'https://www.google.com/recaptcha/api/siteverify';
	$data = array(
		'secret' => '6LdQ03IUAAAAAEcHLHukEBHML-g8FFy6zqohXNZQ',
		'response' => $_POST["g-recaptcha-response"]
	);
	$options = array(
		'http' => array (
			'method' => 'POST',
			'content' => http_build_query($data)
		)
	);
	
	$context  = stream_context_create($options);
	$verify = file_get_contents($url, false, $context);
	$captcha_success=json_decode($verify); 
	if ($captcha_success->success==false) {
		$loc= "Location: ".$_SERVER['HTTP_HOST']."/autyzm";
		//$uri = "Location: ".$_SERVER['HTTP_HOST']."/autyzm";
		header("Location: http://".$_SERVER['HTTP_HOST']."/autyzm", true, 302);
		die();
	} else if ($captcha_success->success==true) { 
		$to = $sender_email;
		$subject = 'Wynik testu:'.$sender_message;
		$message = 'Wynik testu</br> ';
		$headers = 'From: casstomdev@example.com' . "\r\n" .
			'Reply-To: casstomdev@gmail.com' . "\r\n" .
			'X-Mailer: PHP/' . phpversion();

		mail($to, $subject, $message, $headers); 
		header("Location: http://".$_SERVER['HTTP_HOST']."/autyzm/sendresult", true, 302);
		die();
	}