<?php
include '../fonctions.php';
require_once('recaptchalib.php');
$privatekey = "YOUR PRIVATE KEY HERE";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
} else {
// Your code here to handle a successful verification
if($_POST['likesubmit'] == ""){
echo'<script type="text/javascript">window.location = "?"; </script>';
}else{
$posted = mysql_real_escape_string(htmlentities($_POST[likesubmit],ENT_QUOTES));
$bad = array("\\");
$checkposted = str_replace($bad,"", $posted);
$stripped= strip_tags($checkposted);
mysql_query("INSERT INTO `likes` (`title`, `numLikes`) VALUES ('$stripped', '0')");
$select = mysql_query("SELECT * FROM `likes` WHERE `title`='$stripped' AND `numLikes`='0'ORDER BY `id` DESC LIMIT 1 ");
$fetch = mysql_fetch_array($select);
echo'<script type="text/javascript">window.location = "../view.php?id='.$fetch[id].'"; </script>';
}
}
?>