Oh ik dacht captcha tegen mailheader-injection was.
->GRATIS<- Contact script
Er zijn nog heel veel andere manieren. Met sessies kan je meestal wel leuke dingen doen.
Dylanh schreef:toevoeging op 23 februari 2013, 22:31:50:Oh ik dacht captcha tegen mailheader-injection was.
Nee, en daar kan je ook geen SQL-injection mee beveiligen.
Rogier schreef:Eens... Ideaal om spamruns tegen te gaan, en het versturen te kunnen limiteren met een interval van enkele secondes tot minuten.Er zijn nog heel veel andere manieren. Met sessies kan je meestal wel leuke dingen doen.
Dylanh schreef:Misschien dat deze wat beter is:
[COLOR= #0000BB]<?php
$jouwmail[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]jouwadreshier@domein.nl[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/define"]define[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$jouwmail[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REQUEST_METHOD[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]POST[/COLOR][COLOR= #007700]) {[/COLOR] [COLOR= #FF8000]// als het forumiel gepost is...[/COLOR]
[COLOR= #0000BB]$errors[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR]filter_var[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]],[/COLOR] FILTER_VALIDATE_EMAIL[COLOR= #007700])) {[/COLOR] [COLOR= #FF8000]// als het email een goede email is[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/trim"]trim[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]yourname[/COLOR][COLOR= #007700]]) ==[/COLOR] [COLOR= #DD0000][/COLOR] [COLOR= #007700]||[/COLOR] [URL="http://www.php.net/trim"]trim[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]onderwerp[/COLOR][COLOR= #007700]]) ==[/COLOR] [COLOR= #DD0000][/COLOR] [COLOR= #007700]||[/COLOR] [URL="http://www.php.net/trim"]trim[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]how[/COLOR][COLOR= #007700]]) ==[/COLOR] [COLOR= #DD0000][/COLOR] [COLOR= #007700]||[/COLOR] [URL="http://www.php.net/trim"]trim[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]comments[/COLOR][COLOR= #007700]]) ==[/COLOR] [COLOR= #DD0000][/COLOR] [COLOR= #007700]||[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]TOS[/COLOR][COLOR= #007700]] ==[/COLOR] false[COLOR= #007700]) {[/COLOR] [COLOR= #FF8000]// als er iets niet ingevuld is.[/COLOR]
[COLOR= #0000BB]$errors[/COLOR][COLOR= #007700][] =[/COLOR] [COLOR= #DD0000]U heeft één of meerdere velden niet ingevuld.[/COLOR][COLOR= #007700];
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR] [COLOR= #FF8000]// als alles ingevuld is[/COLOR]
[COLOR= #0000BB]$bericht[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]
Beste,
Iemand heeft het contact formulier ingevuld. Hierbij de gegevens:
Naam: [/COLOR][COLOR= #007700].[/COLOR]htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]yourname[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000] n
Email Adres: [/COLOR][COLOR= #007700].[/COLOR]htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000] n
Onderwerp: [/COLOR][COLOR= #007700].[/COLOR]htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]onderwerp[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000] n
Hoe gevonden: [/COLOR][COLOR= #007700].[/COLOR]htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]how[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000] n
IP Adres: [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000] n
Verstuurd op: [/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/date"]date[/URL][COLOR= #007700]().[/COLOR][COLOR= #DD0000] n
Bericht: [/COLOR][COLOR= #007700].[/COLOR]htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]comments[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000] n
[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$headers[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]From: [/COLOR][COLOR= #007700].[/COLOR]htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]yourname[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000] <[/COLOR][COLOR= #007700].[/COLOR]htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]>rn[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$headers[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"MIME-Version: 1.0rn"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$headers[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"Content-type: text/html; charset=iso-8859-1rn"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$headers[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"Return-Path: Mail-Error <"[/COLOR][COLOR= #007700].[/COLOR]email[COLOR= #007700].[/COLOR][COLOR= #DD0000]">rn"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$headers[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"Reply-To: "[/COLOR][COLOR= #007700].[/COLOR]htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]yourname[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]" <"[/COLOR][COLOR= #007700].[/COLOR]htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]">rn"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$headers[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"Bcc: "[/COLOR][COLOR= #007700].[/COLOR]htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]"rn"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$subject[/COLOR] [COLOR= #007700]=[/COLOR] htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]onderwerp[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$to[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]];
}
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$errors[/COLOR][COLOR= #007700][] =[/COLOR] [COLOR= #DD0000]Uw email adres voldoet niet aan onze eisen.[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/count"]count[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$errors[/COLOR] [COLOR= #007700]>=[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]De volgende fouten zijn opgetreden: <br />[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$errors[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$error[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$error[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]<br />[/COLOR][COLOR= #007700];
}
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$mail[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mail"]mail[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$to[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$subject[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$bericht[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$headers[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$mail[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Email is succesvol vestuurd.[/COLOR][COLOR= #007700];
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Oeps, er is iets mis gegaan met het versturen van de email. Probeer het later nog eens.[/COLOR][COLOR= #007700];
}
}
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
?>
<html>
<body>
<form action="#" method="post">
<b>Uw naam:</b><br />
<input type="text" name="yourname" /><br /><br />
<b>Uw e-mailadres:</b><br />
<input type="text" name="email" size="30px"/>
<br /> <br />
<b>Het onderwerp van uw bericht:</b><br />
<input type="radio" name="onderwerp" value="Vraag" checked="checked" /> Vraag
<input type="radio" name="onderwerp" value="Bestelling" /> Bestelling
<input type="radio" name="onderwerp" value="klacht" /> Klacht
<input type="radio" name="onderwerp" value="Overige" /> Overige<br />
<br />
<b>Hoe heeft u ons gevonden?</b><br />
<select name="how">
<option>Wil ik liever niet melden</option>
<option>Google</option>
<option>Mond tot mond reclame</option>
<option>Link vanaf een andere website</option>
<option>Overige</option>
</select>
<br /> <br />
<b>Uw bericht:</b><br />
<i>*Geef zoveel mogelijk details in geval van een klacht.</i><br />
<textarea name="comments" rows="20" cols="60" class="textarea"></textarea><br>
<input type="checkbox" name="TOS" value="TOS">Ik accepteer de algemene voorwaarden en ik maak geen misbruik van dit contact formulier.<br>
<input type="submit" value="verstuur" name="verstuur"> <input type="reset" value="Verwijder velden" />
</form>
</body>
</html>
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]}[/COLOR]
?> Let op: Er moet nog een captcha in komen. Dit mag je er zelf inbouwen of wachten tot morgen want dan bouw ik er ook een captcha in

toevoeging op 23 februari 2013, 20
43:En het is (nog) niet getest.
Eerst stop je de mail in een var, dan in een define. Het is 1 van de 2 of gewoon geen.
hmah dat is niet waar. Echter vind ik een define hier überhaupt overbodig.
Morgen fixt ik het.
Als je een captcha implementeert, voeg dan wel een boolean toe waarmee je kan kiezen of je de captcha wilt gebruiken.
Joeey schreef:Waarom in godsnaam? Als je hem niet wil kan je hem er in 3 sec uitslopen of gebruik je contact script hierboven.Als je een captcha implementeert, voeg dan wel een boolean toe waarmee je kan kiezen of je de captcha wilt gebruiken.
Stuurt je contact script nou een mail naar het mail adres dat je net hebt ingevuld?
Moet regel 33 niet zo worden?
Moet regel 33 niet zo worden?
$to = $jouwmail; Die hele regel is overbodig, waarom variabelen in een nieuwe var schrijven, zonder dat je er een bewerking over heen gooit
....
....Aarclay schreef:Klopt, maar nu slaat het al helemaal nergens opDie hele regel is overbodig, waarom variabelen in een nieuwe var schrijven, zonder dat je er een bewerking over heen gooit....

Rogier schreef:Overzichtelijkheid... Ik heb altijd een configuratie file (meestal gebruik ik classes om array data te loaden en bewerken, maar dat is hier niet echt nodig) waarin ik meestal wel een paar booleans en integers heb.Waarom in godsnaam? Als je hem niet wil kan je hem er in 3 sec uitslopen of gebruik je contact script hierboven.Eerdere citaten tonen
Joeey schreef:Als je een captcha implementeert, voeg dan wel een boolean toe waarmee je kan kiezen of je de captcha wilt gebruiken.