if($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST))
{
$aFouten = array();
if($_POST['voornaam'] == '')
{
$aFouten[] = 'Je hebt geen voornaam ingevuld';
}if($_POST['track'] == '')
{
$aFouten[] = 'Je hebt nog geen openingsnummer gekozen!';
}
if(count($aFouten) != 0)
{
echo "<div id=\"fouten\">
De volgende fouten zijn opgetreden bij het invoeren van je gegevens:
<BR /><ul type=\"square\">";
for($Fi = 0; $Fi < count($aFouten); $Fi++)
{
echo "<li>".$aFouten[$Fi]."</li>";
}
echo "</ul>
<a href=\"javascript:history.go(-1);\" class=\"linkterug\">Klik hier om terug te keren en het formulier goed in te vullen.</a>
</div>";
}
else
{
require_once('recaptchalib.php');
// Get a key from https://www.google.com/recaptcha/admin/create
$publickey = "6LeyXs4SAAAAACeQhD2pbOPYFJsjuF8bLwYblu-D";
$privatekey = "6LeyXs4SAAAAAEzvulClhzKLhRuqO_MlqnKps9VQ";
# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = 'De reCAPTCHA code klopt niet. Probeer het opnieuw';
# was there a reCAPTCHA response?
if ($_POST["recaptcha_response_field"]) {
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if ($resp->is_valid) {
echo "You got it!";
} else {
# set the error code so that we can display it
$error = $resp->error;
}
}
mysql_query("INSERT INTO bruiloft (voornaam,track) VALUES ('".mysql_real_escape_string($_POST['voornaam'])."','".mysql_real_escape_string($_POST['track'])."')") or die (mysql_error());
}
}
else
{
?>
Verderop staat het formulier als volgt:
<form method="POST" action="poll.php">
<table border="0" width="100%">
<tr>
<td width="45%">
Voornaam:
</td>
<td width="55%">
<input type="text" name="voornaam" id="voornaam" size="20" maxlength="30" />
</td>
</tr>
<tr>
<td width="45%">
Met welk nummer moeten we het feest openen?
</td>
<td width="55%">
<select name="track" id="track">
<option value="" SELECTED>Maak een keuze</option>
<option value="move like jagger">Maroon 5 ft. Christina Aguilera - Move Like Jagger</option>
<option value="sex on fire">Kings of Leon - Sex on Fire</option>
</select>
</td>
</tr>
<tr>
<td width="45%">
</td>
<td width="55%">
<?php
require_once('recaptchalib.php');
// Get a key from https://www.google.com/recaptcha/admin/create
$publickey = "6LeyXs4SAAAAACeQhD2pbOPYFJsjuF8bLwYblu-D";
echo recaptcha_get_html($publickey, $error);
?>
</td>
</tr>
<tr>
<td width="45%">
</td>
<td width="55%">
<input type="reset" name="reset" value="Beginwaarden" />
<input type="submit" name="submit" value="Verzenden" />
</td>
</tr>
</table>
</form>