Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
38 lines (29 sloc) 1.07 KB
// require sweetcaptcha php sdk, don't forget to set up your credentials first
if (empty($_POST)) {
// print sweetcaptcha in your form
<form method="post">
<p>This is your form you like SweetCapcha to protect</p>
<p>You can set up it normally as you like <input type="text" name="name" value="" placeholder="Name" /></p>
<!-- implement sweetcaptcha -->
<?php echo $sweetcaptcha->get_html() ?>
<!-- continue with your form -->
<input type="submit" />
} else {
// looks like someone has submitted a form, let's validate it
if (isset($_POST['sckey']) and isset($_POST['scvalue']) and $sweetcaptcha->check(array('sckey' => $_POST['sckey'], 'scvalue' => $_POST['scvalue'])) == "true") {
// success! your form was validated
// do what you like next ...
echo "Success! carry on if you will";
else {
// alas! the validation has failed, the user might be a spam bot or just got the result wrong
// handle this as you like
echo "Boohoo! captcha validation failed!";