Janni
unregistriert
Captcha in Kontakformular Script
Hallo,
ich habe ein kleines Kontaktformular, und möchte dort nun eine Captcha Funktion hinzufügen. Ich kriege es aber nicht hin. Habe bei google schon gesucht, doch das Funktioniert alles einfach nicht. Vielleicht kann mir jemand helfen.
hier mein Script, welches ich nutze. (Nicht für das Kit)
kontaktformular-script.php
kontakt.htm
Ich danke für Hilfe!
ich habe ein kleines Kontaktformular, und möchte dort nun eine Captcha Funktion hinzufügen. Ich kriege es aber nicht hin. Habe bei google schon gesucht, doch das Funktioniert alles einfach nicht. Vielleicht kann mir jemand helfen.
hier mein Script, welches ich nutze. (Nicht für das Kit)
kontaktformular-script.php
|
|
PHP-Quelltext |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
<?php
$Empfaenger = "mail@adresse.de";
if($_REQUEST['Send'])
{
if(empty($_REQUEST['Name']) || empty($_REQUEST['Email']) || empty($_REQUEST['Nachricht']))
{
echo"Bitte gehen Sie <a href=\"javascript:history.back();\">zurück</a> und füllen Sie alle Felder aus!";
}
else
{
$Mailnachricht = "Sie haben folgende Nachricht erhalten: \n\n";
while(list($Formularfeld, $Wert)=each($_REQUEST))
{
if($Formularfeld!="Send")
{
$Mailnachricht .= $Formularfeld.": ".$Wert."\n";
}
}
$Mailnachricht .= "\nDatum/Zeit: ";
$Mailnachricht .= date("d.m.Y H:i:s");
$Mailbetreff = "Kontakt: ";
$Mailbetreff .= $_REQUEST['Betreff'];
mail($Empfaenger, $Mailbetreff, $Mailnachricht, "From: ".$_REQUEST['Email']);
echo"Vielen Dank für Ihre E-Mail!";
}
}
else
{
echo"Ein Fehler ist aufgetreten. Bitte überprüfen Sie ihre Angaben. [<a href=\"kontakt.php\">Zurück</a>]";
}
?>
|
kontakt.htm
|
|
PHP-Quelltext |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
<table border="0" cellpadding="1" cellspacing="2" id="table2">
<form action="kontaktformular-script.php" method="post">
<tr>
<td class="hell"><font size="2" face="Tahoma">Name:</font></td>
<td class="hell">
<input name="Name" size="42" type="text" style="font-family: Tahoma; font-size: 10pt; color: #000000; background-color: #D7D7D7"></td>
</tr>
<tr>
<td class="hell"><font size="2" face="Tahoma">E-Mail:</font></td>
<td class="hell">
<input name="Email" size="42" type="text" style="color: #000000; font-family: Tahoma; font-size: 10pt; background-color: #d7d7d7"></td>
</tr>
<tr>
<td class="hell"><font size="2" face="Tahoma">Betreff:</font></td>
<td class="hell">
<select name="Betreff" size="1" style="font-family: Tahoma; font-size: 10pt; background-color: #d7d7d7"><option>
Hilfe</option>
<option>Frage</option><option>Problem</option></select></td>
</tr>
<tr>
<td class="hell"><font size="2" face="Tahoma">Nachricht:</font></td>
<td class="hell">
<textarea cols="69" name="Nachricht" rows="8" style="background-position: center; color: #000000; font-family: Tahoma; font-size: 10pt; background-color:#D7D7D7; background-image:url('images/eingabebg.gif'); background-repeat:no-repeat"></textarea></td>
</tr>
<tr>
<td align="center" colspan="2" class="hell"><input name="Send" type="submit" value="Abschicken"> <input name="Reset" type="reset" value="Löschen"></td>
</tr>
</form>
</table>
|
Ich danke für Hilfe!
Huhu,
also folgendes: (basierend auf deinem Script)
kontaktformular-script.php
kontakt.htm
captcha.php
Und dann brauchst du noch die Schrifttypen sowie Hintergrund Datei, die gibts hier: Klick
(Anhängen geht nich da ein Schrifttyp ca 90kb hat und die maximale Dateigröße hier 50 kb ist
)
Einfach in den Ordner kopieren wo dein Kontaktscript liegt.
Müsste eigentlich funktionieren, aber keine Garantie
greetz 2Bad4You
also folgendes: (basierend auf deinem Script)
kontaktformular-script.php
|
|
PHP-Quelltext |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
<?php
session_start();
$Empfaenger = "mail@adresse.de";
if($_REQUEST['Send'])
{
if(empty($_REQUEST['Name']) || empty($_REQUEST['Email']) || empty($_REQUEST['Nachricht']))
{
echo"Bitte gehen Sie <a href=\"javascript:history.back();\">zurück</a> und füllen Sie alle Felder aus!";
}
if (md5($_POST['sicherheitscode']) != $_SESSION['captcha_code'])
{
echo "Der eingegebene Sicherheitscode ist falsch! <a href=\"javascript:history.back();\">zurück</a>";
}
else
{
$Mailnachricht = "Sie haben folgende Nachricht erhalten: \n\n";
while(list($Formularfeld, $Wert)=each($_REQUEST))
{
if($Formularfeld!="Send")
{
$Mailnachricht .= $Formularfeld.": ".$Wert."\n";
}
}
$Mailnachricht .= "\nDatum/Zeit: ";
$Mailnachricht .= date("d.m.Y H:i:s");
$Mailbetreff = "Kontakt: ";
$Mailbetreff .= $_REQUEST['Betreff'];
mail($Empfaenger, $Mailbetreff, $Mailnachricht, "From: ".$_REQUEST['Email']);
echo"Vielen Dank für Ihre E-Mail!";
}
}
else
{
echo"Ein Fehler ist aufgetreten. Bitte überprüfen Sie ihre Angaben. [<a href=\"kontakt.php\">Zurück</a>]";
}
?>
|
kontakt.htm
|
|
PHP-Quelltext |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
<table border="0" cellpadding="1" cellspacing="2" id="table2">
<form action="kontaktformular-script.php" method="post">
<tr>
<td class="hell"><font size="2" face="Tahoma">Name:</font></td>
<td class="hell">
<input name="Name" size="42" type="text" style="font-family: Tahoma; font-size: 10pt; color: #000000; background-color: #D7D7D7"></td>
</tr>
<tr>
<td class="hell"><font size="2" face="Tahoma">E-Mail:</font></td>
<td class="hell">
<input name="Email" size="42" type="text" style="color: #000000; font-family: Tahoma; font-size: 10pt; background-color: #d7d7d7"></td>
</tr>
<tr>
<td class="hell"><font size="2" face="Tahoma">Betreff:</font></td>
<td class="hell">
<select name="Betreff" size="1" style="font-family: Tahoma; font-size: 10pt; background-color: #d7d7d7"><option>
Hilfe</option>
<option>Frage</option><option>Problem</option></select></td>
</tr>
<tr>
<td class="hell"><font size="2" face="Tahoma">Nachricht:</font></td>
<td class="hell">
<textarea cols="69" name="Nachricht" rows="8" style="background-position: center; color: #000000; font-family: Tahoma; font-size: 10pt; background-color:#D7D7D7; background-image:url('images/eingabebg.gif'); background-repeat:no-repeat"></textarea></td>
</tr>
<tr>
<td class="hell"><font size="2" face="Tahoma">Captcha:</font></td>
<td class="hell">
<img src="captcha.php" alt="Sicherheitscode" title="Sicherheitscode" width="80" height="25" /> = <input type="text" size="6" maxlength="6" name="sicherheitscode" id="sicherheitscode" /></td>
</tr>
<tr>
<td align="center" colspan="2" class="hell"><input name="Send" type="submit" value="Abschicken"> <input name="Reset" type="reset" value="Löschen"></td>
</tr>
</form>
</table>
|
captcha.php
|
|
PHP-Quelltext |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
<?php
// Session starten
session_start();
// Alten CAPTCHA-Code aus der Session loeschen
unset( $_SESSION['captcha_code'] );
// Das Cachen der Grafik verhindern
header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" );
header( "Cache-Control: no-store, no-cache, must-revalidate" );
header( "Cache-Control: post-check=0, pre-check=0", false );
header( "Pragma: no-cache" );
// Dem Browser mitteilen das es sich hierbei um ein JPG handelt.
header( 'Content-type: image/jpeg' );
// Sicherheitscode generieren
$AlphaNumerischerString = "ABCDEFGH2345689";
$ZufallString1 = substr( str_shuffle( $AlphaNumerischerString ), 0, 2 );
$ZufallString2 = substr( str_shuffle( $AlphaNumerischerString ), 0, 2 );
$ZufallString3 = substr( str_shuffle( $AlphaNumerischerString ), 0, 2 );
$ZufallStringKomplett = $ZufallString1.$ZufallString2.$ZufallString3;
// Sicherheitscode in der Session speichern
$_SESSION['captcha_code'] = md5( $ZufallStringKomplett );
// Grafik erzeugen und an den Browser senden
$Schriftarten = array( "zachary.ttf", "mtcorsva.ttf", "gilligan.ttf");
$Bilddatei = imagecreatefrompng( "hintergrund.png" );
$TextFarbe1 = imagecolorallocate( $Bilddatei, 0, 125, 0 );
$TextFarbe2 = imagecolorallocate( $Bilddatei, 130, 70, 90 );
$TextFarbe3 = imagecolorallocate( $Bilddatei, 180, 90, 190 );
imagettftext( $Bilddatei, 12, 15, 3, 24, $TextFarbe1, $Schriftarten[0], $ZufallString1 );
imagettftext( $Bilddatei, 16, 0, 26, 15, $TextFarbe2, $Schriftarten[1], $ZufallString2 );
imagettftext( $Bilddatei, 14, -20, 53, 18, $TextFarbe3, $Schriftarten[2], $ZufallString3 );
imagejpeg( $Bilddatei );
// Grafik zerstoeren und Speicher freigeben
imagedestroy( $Bilddatei );
?>
|
Und dann brauchst du noch die Schrifttypen sowie Hintergrund Datei, die gibts hier: Klick
(Anhängen geht nich da ein Schrifttyp ca 90kb hat und die maximale Dateigröße hier 50 kb ist
)Einfach in den Ordner kopieren wo dein Kontaktscript liegt.
Müsste eigentlich funktionieren, aber keine Garantie

greetz 2Bad4You
Janni
unregistriert
Danke für deine Hilfe, bekomme nur immer diesen Fehler:
Das Problem hatte ich auch schon, als ich den Captcha von stoppt-den-spam.de eingebaut hatte.
|
|
Quellcode |
1 |
Warning: imagettftext() [function.imagettftext]: Could not read font in C:\xampp\htdocs\website\captcha.php on line 33 |
Das Problem hatte ich auch schon, als ich den Captcha von stoppt-den-spam.de eingebaut hatte.
hm ok komich. Weil das Captcha an sich geht, siehe hier
Dann scheint irgendwas mit deinem Xampp nicht zu stimmen, welche Version benutzt du? Und welche PHP Version?
Dann scheint irgendwas mit deinem Xampp nicht zu stimmen, welche Version benutzt du? Und welche PHP Version?
Ähnliche Themen
-
alte Versionen [1.6.03|1.6.1|1.6.4] »-
Problem mit Kontaktformular
(22. Juni 2008, 03:04)
-
Web | Allgemein »-
Easteregg
(12. Mai 2008, 20:39)
-
alte Versionen [1.6.03|1.6.1|1.6.4] »-
Suche für kontakformular ein script
(3. Mai 2008, 13:57)
-
Webhosting / Webserver »-
XAMPP GDlib bzw Captcha Problem
(8. Januar 2008, 00:07)


