Beste Leden,
Ik heb een contactformulier, alleen is deze ook aniti-spam? Zo niet hoe bouw ik er makkelijk captcha in?
Code:if(!ctype_digit($_POST['telefoon'])) $telefoon_fout = 1; // E-mailadres van de ontvanger $mail_ontv =; // <<<----- voer jouw e-mailadres hier in! // Speciale checks voor naam en e-mailadres if ($_SERVER['REQUEST_METHOD'] == 'POST') { // naam controle if (empty($_POST['naam'])) $naam_fout = 1; // plaats controle if (empty($_POST['woonplaats'])) $woonplaats_fout = 1; // telefoonnummer controle if (empty($_POST['telefoon'])) $telefoon_fout = 1; elseif(!empty($telefoon_fout)) echo 'Uw telefoonnummer mag alleen uit cijfers bestaan'; //adres controle if (empty($_POST['adres'])) $adres_fout = 1; // e-mail controle if (function_exists('filter_var') && !filter_var($_POST['mail'], FILTER_VALIDATE_EMAIL)) $email_fout = 1; // antiflood controle if (!empty($_SESSION['antiflood'])) { $seconde = 20; // 20 seconden voordat dezelfde persoon nog een keer een e-mail mag versturen $tijd = time() - $_SESSION['antiflood']; if($tijd < $seconde) $antiflood = 1; } } // Kijk of alle velden zijn ingevuld - naam mag alleen uit letters bestaan en het e-mailadres moet juist zijn if (($_SERVER['REQUEST_METHOD'] == 'POST' && (!empty($antiflood) || empty($_POST['naam']) || !empty($naam_fout) || empty($_POST['adres']) || !empty($adres_fout) || !empty($kenteken_fout) || empty($_POST['telefoon']) || !empty($telefoon_fout) || empty($_POST['woonplaats']) || !empty($woonplaats_fout)|| empty($_POST['mail']) || !empty($email_fout) || empty($_POST['bericht']) || empty($_POST['onderwerp']))) || $_SERVER['REQUEST_METHOD'] == 'GET') { if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (!empty($naam_fout)) echo '<p>Uw naam is niet ingevuld.</p>'; elseif (!empty($email_fout)) echo '<p>Uw e-mailadres is niet juist.</p>'; elseif (!empty($telefoon_fout)) echo '<p>Uw telefoon nummer is niet juist.</p>'; elseif (!empty($woonplaats_fout)) echo '<p>Uw woonplaats is niet juist.</p>'; elseif (!empty($adres_fout)) echo '<p>Uw adres is niet juist.</p>'; elseif (!empty($antiflood)) echo '<p>U mag slechts één bericht per ' . $seconde . ' seconde versturen.</p>'; else echo '<p>U bent het onderwerp of bericht vergeten in te vullen.</p>'; } // HTML e-mail formlier echo '<form method="post" action="' . $_SERVER['REQUEST_URI'] . '" /> <h1>Contactformulier</h1> <div class="clearfix"> <div class="w48 floatleft"> <label for="naam">Naam:</label> <input type="text" class="w96" id="naam" name="naam" value="' . (isset($_POST['naam']) ? htmlspecialchars($_POST['naam']) : '') . '" /> </div> <div class="w48 floatright"> <label for="woonplaats">Woonplaats:</label> <input type="text" class="w96" id="woonplaats" name="woonplaats" value="' . (isset($_POST['woonplaats']) ? htmlspecialchars($_POST['woonplaats']) : '') . '" /> </div> </div> <div class="clearfix"> <div class="w48 floatleft"> <label for="adres">Adres:</label> <input type="text" class="w96" id="adres" name="adres" value="' . (isset($_POST['adres']) ? htmlspecialchars($_POST['adres']) : '') . '" /> </div> <div class="w48 floatright"> <label for="telefoon">Telefoonnummer:</label> <input type="text" class="w96" id="telefoon" name="telefoon" value="' . (isset($_POST['telefoon']) ? htmlspecialchars($_POST['telefoon']) : '') . '" /> </div> </div> <div class="clearfix"> <div class="w48 floatright"> <label for="mail">E-mailadres:</label> <input type="text" class="w96" id="mail" name="mail" value="' . (isset($_POST['mail']) ? htmlspecialchars($_POST['mail']) : '') . '" /> </div> <div class="w48 floatleft"> <label for="onderwerp">Onderwerp:</label> <input type="text" class="w96" id="onderwerp" name="onderwerp" value="' . (isset($_POST['onderwerp']) ? htmlspecialchars($_POST['onderwerp']) : '') . '" /> </div> </div> <label for="bericht">Bericht:</label> <textarea id="bericht" name="bericht" class="w98" rows="6" cols="40" style="height: 80px;">' . (isset($_POST['bericht']) ? htmlspecialchars($_POST['bericht']) : '') . '</textarea> </div> </div> <div class="clearfix" style="margin-top: 15px;"> <input type="submit" name="submit" value=" Versturen " /> </div> </form>'; } // versturen naar else { // set datum $datum = date('d/m/Y H:i:s'); $inhoud_mail = "===================================================\n"; $inhoud_mail .= "Ingevulde contact formulier " . $_SERVER['HTTP_HOST'] . "\n\n"; $inhoud_mail .= "===================================================\n\n"; $inhoud_mail .= "Naam: " . htmlspecialchars($_POST['naam']) . "\n"; $inhoud_mail .= "E-mailadres: " . htmlspecialchars($_POST['mail']) . "\n"; $inhoud_mail .= "Woonplaats: " . htmlspecialchars($_POST['woonplaats']) . "\n"; $inhoud_mail .= "Telefoonnummer: " . htmlspecialchars($_POST['telefoon']) . "\n"; $inhoud_mail .= "Adres: " . htmlspecialchars($_POST['adres']) . "\n"; $inhoud_mail .= "Bericht:\n\n"; $inhoud_mail .= htmlspecialchars($_POST['bericht']) . "\n\n\n"; $inhoud_mail .= "------------------------------------------------\n"; $inhoud_mail .= "Verstuurd op " . $datum . " via het IP adres " . $_SERVER['REMOTE_ADDR'] . "\n\n"; // -------------------- // spambot protectie // ------ // van de tutorial: http://www.phphulp.nl/php/tutorial/b...rmulieren/340/ // ------ $headers = 'From: ' . htmlspecialchars($_POST['naam']) . ' <' . $_POST['mail'] . '>'; $headers = stripslashes($headers); $headers = str_replace('\n', '', $headers); // Verwijder \n $headers = str_replace('\r', '', $headers); // Verwijder \r $headers = str_replace("\"", "\\\"", str_replace("\\", "\\\\", $headers)); // Slashes van quotes $_POST['onderwerp'] = str_replace('\n', '', $_POST['onderwerp']); // Verwijder \n $_POST['onderwerp'] = str_replace('\r', '', $_POST['onderwerp']); // Verwijder \r $_POST['onderwerp'] = str_replace("\"", "\\\"", str_replace("\\", "\\\\", $_POST['onderwerp'])); // Slashes van quotes if (mail($mail_ontv, $_POST['onderwerp'], $inhoud_mail, $headers)) { // zorg ervoor dat dezelfde persoon niet kan spammen $_SESSION['antiflood'] = time(); echo '<h1>Het contactformulier is verzonden</h1> <p>Bedankt voor het invullen van het contactformulier. We zullen zo spoedig mogelijk contact met u opnemen.</p>'; } else { echo '<h1>Het contactformulier is niet verzonden</h1> <p><b>Onze excuses.</b> Het contactformulier kon niet verzonden worden.</p>'; } } ?> </body> </html>
- Captcha Hulp
-
03-07-2012, 08:56 #1
- Berichten
- 1.190
- Lid sinds
- 14 Jaar
Captcha Hulp
Laatst aangepast door Miichelle G : 03-07-2012 om 09:06
-
In de schijnwerper
BTW berekenen | Toffe tool, 60 blogs & Affiliate pagina | Hoge zoekvolumes (74K)Website te koopTe koop: Kant-en-klare dropshipping webshop in premium huisdierenvoedingWebsite te koopwegens beëindiging bedrijf beschikbaar | KofferStunt.nl DA11 - DR22Website te koopSupersnelle WordPress Webhosting vanaf € 3,00 per maandHosting -
03-07-2012, 09:18 #2
- Berichten
- 1.031
- Lid sinds
- 17 Jaar
Re: Captcha Hulp
Is niet bestand tegen spam.
Spam is niet alleen vele berichten achterelkaar versturen (waarvoor er nu een controle in je script zit) maar ook ongewenste berichte via spam-robots.
Deze robots kan je alleen tegen houden met een Captcha.
Gebruik die van google:
http://www.google.com/recaptcha/captcha
Plaats een
- + Advertentie
- + Onderwerp
Marktplaats
Webmasterforum
- Websites algemeen
- Sitechecks
- Marketing
- Domeinen algemeen
- Waardebepaling
- CMS
- Wordpress
- Joomla
- Magento
- Google algemeen
- SEO
- Analytics
- Adsense
- Adwords
- HTML / XHTML
- CSS
- Programmeren
- PHP
- Javascript
- JQuery
- MySQL
- Ondernemen algemeen
- Belastingen
- Juridisch
- Grafisch ontwerp
- Hosting Algemeen
- Hardware Info
- Offtopic