Hallo, ich habe das Script von der Website genommen um einen Captcha ins Formular einzubinden, leider funktioniert es nicht so ganz, könnte mir wohl jmnd. weiterhelfen
->
Code:
<style type="text/css">
<!--
.Stil6 {
font-size: 24px;
font-weight: bold;
}
.Stil7 {
font-size: 12px;
font-style: italic;
font-weight: bold;
}
.Stil8 {color: #666666}
.Stil11 {font-size: 12px;}
.Stil12 {font-size: 14px}
.Stil14 {font-weight: bold; font-size: 10px;}
-->
</style>
<script type="text/javascript">
<!--
function resetit(FormularfürProduktfragen){
if(confirm("Sicher, dass Ihre Eingaben gelöscht werden sollen?")){
return true
}else{
return false
}
}
-->
</script>
<?php
if(!isset($_GET['do'])) {
echo '
<div style="padding-left: 25px;">
<img style="float:left" src="rule.png" />
<p style="padding-left:10px"><span class="Stil6">Kontakt</span><br />
<span class="Stil7">Lassen sie uns reden!</span><br />
<span class="Stil8">__________________________________________________</span></p>
</div>
<div style="padding-left: 50px; padding-right: 200px; padding-top: 10px;">
<form name="FormularfürProduktfragen" action="?show=kontakt&do=send" method="post" onreset="return resetit(this)" lang="JavaScript">
<table width="50%">
<tr>
<td><span class="Stil1 Stil12"><strong>Formular für Produktnachfragen</strong></span></td>
</tr>
<tr>
<td valign="middle"><span class="Stil8">____________________________________</span></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td style="border-style: none; border-width: medium" align="left">
<select name="Betreff" size="1">
<option selected="selected" value="0">--- Betreff ---</option>
<option value="Allgemein"> Allgemein </option>
<option value="Programmierung"> Programmierung </option>
<option value="Suchmaschienenoptimierung"> Suchmaschienenoptimierung </option>
<option value="Shop"> Online-Shop </option>
</select></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td style="border-style: none; border-width: medium" align="left">
<select name="Anrede" size="1">
<option selected="selected" value="0"> Anrede </option>
<option value="Herr"> Herr </option>
<option value="Frau"> Frau </option>
</select></td>
</tr>
<tr>
<td style="border-style: none; border-width: medium" align="left">
<input size="40%" name="Vorname" class="Stil1" value="Vorname" onFocus="if(this.value==\'Vorname\'){ this.value=\'\'; this.style.color=\'#000000\'}" onBlur="if(this.value==\'\'){this.value=\'Vorname\';this.style.color=\'#666666\'}" style="border:2px solid #666666; color: #666666; background-color:#FFFFFF" title="Vorname" /></td>
</tr>
<tr>
<td style="border-style: none; border-width: medium" align="left">
<input size="40%" name="Name" class="Stil1" value="Name*" onFocus="if(this.value==\'Name*\'){ this.value=\'\'; this.style.color=\'#000000\'}" onBlur="if(this.value==\'\'){this.value=\'Name*\';this.style.color=\'#666666\'}" style="border:2px solid #666666; color: #666666; background-color:#FFFFFF" title="Name" /></td>
</tr>
<tr>
<td style="border-style: none; border-width: medium" align="left">
<input size="40%" name="Anschrift" class="Stil1" value="Anschrift" onFocus="if(this.value==\'Anschrift\'){ this.value=\'\'; this.style.color=\'#000000\'}" onBlur="if(this.value==\'\'){this.value=\'Anschrift\';this.style.color=\'#666666\'}" style="border:2px solid #666666; color: #666666; background-color:#FFFFFF" title="Anschrift" /></td>
</tr>
<tr>
<td style="border-style: none; border-width: medium" align="left">
<input size="7%" name="PLZ" class="Stil1" value="PLZ" onFocus="if(this.value==\'PLZ\'){ this.value=\'\'; this.style.color=\'#000000\'}" onBlur="if(this.value==\'\'){this.value=\'PLZ\';this.style.color=\'#666666\'}" style="border:2px solid #666666; color: #666666; background-color:#FFFFFF" title="PLZ" />
<span> </span>
<input size="26%" name="Stadt" class="Stil1" value="Stadt" onFocus="if(this.value==\'Stadt\'){ this.value=\'\'; this.style.color=\'#000000\'}" onBlur="if(this.value==\'\'){this.value=\'Stadt\';this.style.color=\'#666666\'}" style="border:2px solid #666666; color: #666666; background-color:#FFFFFF" title="Stadt" />
</td>
</tr>
<tr>
<td style="border-style: none; border-width: medium" align="left">
<input size="40%" name="Telefon" class="Stil1" value="Telefon*" onFocus="if(this.value==\'Telefon*\'){ this.value=\'\'; this.style.color=\'#000000\'}" onBlur="if(this.value==\'\'){this.value=\'Telefon*\';this.style.color=\'#666666\'}" style="border:2px solid #666666; color: #666666; background-color:#FFFFFF" title="Telefon" /></td>
</tr>
<tr>
<td style="border-style: none; border-width: medium" align="left">
<input size="40%" name="Email" class="Stil1" value="Email*" onFocus="if(this.value==\'Email*\'){ this.value=\'\'; this.style.color=\'#000000\'}" onBlur="if(this.value==\'\'){this.value=\'Email*\';this.style.color=\'#666666\'}" style="border:2px solid #666666; color: #666666; background-color:#FFFFFF" title="Email" /></td>
</tr>
<tr>
<td style="border-style: none; border-width: medium">
<div align="left"><textarea rows="10" cols="39" name="Nachricht" class="Stil1" onFocus="if(this.value==\'Ihre Fragen / Nachricht*\'){ this.value=\'\'; this.style.color=\'#000000\'}" onBlur="if(this.value==\'\'){this.value=\'Ihre Fragen / Nachricht*\';this.style.color=\'#666666\'}" style="border:2px solid #666666; color: #666666; background-color:#FFFFFF; font-family:Verdana, Arial, Helvetica, sans-serifl; font-size:12px" title="Nachricht">Ihre Fragen / Nachricht*</textarea></div></td>
</tr>
<tr>
<td style="border-style: none; border-width: medium" align="left">
<span class="Stil1" style="color:#FFFFFF; font-size:12px;"><strong>Spamschutz:</strong></span></td>
<tr>
<td><img src="captcha/captcha.php" border="0" title="Sicherheitscode"> <input name="sicherheitscode" size="5%"></td>
</tr>
</table>
<p class="Stil1 Stil14"><i>*Pflichtfelder</i></p>
<input name="submit" class="Stil1" type="submit" value="Abschicken" style="color: #000000; border: 2px solid #666666; background-color: #FF0000" /> <input class="Stil1" type="reset" value="Eingaben löschen" style="color: #000000; border: 2px solid #666666; background-color: #FFFFFF" />
</form>
<br /><br />
</div>'; }
if($_GET['do'] == "send") {
if(is_string($_POST['Betreff'])) { if(htmlspecialchars($_POST['Betreff']) == '0') { $e0= '<i><strong>Bitte wählen Sie einen Betreff aus.</strong></i>'; }}
if(is_string($_POST['Anrede'])) { if(htmlspecialchars($_POST['Anrede']) == '0') { $e1= '<i><strong>Bitte wählen Sie eine Anrede aus.</strong></i>'; }}
if(is_string($_POST['Name'])) { if(strlen(htmlspecialchars($_POST['Name'])) <= 1 || $_POST['Name'] == 'Name*') { $e2= '<i><strong>Bitte geben Sie Ihren Namen ein.</strong></i>'; }}
if(is_string($_POST['Telefon'])) { if(strlen(htmlspecialchars($_POST['Telefon'])) <= 1 || $_POST['Telefon'] == 'Telefon*') { $e3= '<i><strong>Bitte geben Sie Ihre Telefonnummer ein.</strong></i>'; }}
if(is_string($_POST['Email'])) { if(strlen(htmlspecialchars($_POST['Email'])) <= 1 || $_POST['Email'] == 'Email*') { $e4= '<i><strong>Bitte geben Sie Ihre Email-Adresse ein.</strong></i>'; }}
if(is_string($_POST['Nachricht'])) { if(strlen(htmlspecialchars($_POST['Nachricht'])) <= 1 || $_POST['Nachricht'] == 'Ihre Fragen / Nachricht*') { $e5= '<i><strong>Bitte geben Sie Ihre Nachricht ein.</strong></i>'; }}
if(isset($_SESSION['captcha_spam']) && $_POST["sicherheitscode"] == $_SESSION['captcha_spam']) { unset($_SESSION['captcha_spam']); } else { $e6= '<i><strong>Ihr Eingabe ist leider falsch, bitte versuchen sie es erneut.</strong></i>'; }
if(strlen($e0) > 2 || strlen($e1) > 2 || strlen($e2) > 2 || strlen($e3) > 2 || strlen($e4) > 2 || strlen($e5) > 2 || strlen($e6) > 2) {
echo '
<div style="padding-left: 25px;">
<img style="float:left" src="rule.png" />
<p style="padding-left:10px"><span class="Stil6">Kontakt</span><br />
<span class="Stil7">Lassen sie uns reden!</span><br />
<span class="Stil8">__________________________________________________</span></p>
</div>
<div style="padding-left: 50px; padding-right: 200px; padding-top: 10px;">
<form name="FormularfürProduktfragen" action="?show=kontakt&do=send" method="post" onreset="return resetit(this)" lang="JavaScript">
<table>
<tr>
<td class="Stil1"><span class="Stil1 Stil12"><strong>Formular für Produktnachfragen</strong></span></td>
<td class="Stil1"> </td>
</tr>
<tr>
<td colspan="2" valign="middle"><span class="Stil8">____________________________________</span></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td style="border-style: none; border-width: medium" align="left">
<select name="Betreff" size="1">
<option '; if(!isset($_POST['Betreff'])) { echo 'selected="selected"'; } echo' value="0">--- Betreff ---</option>
<option '; if(isset($_POST['Betreff']) && $_POST['Betreff'] == "Allgemein") { echo 'selected="selected"'; } echo' value="Allgemein"> Allgemein </option>
<option '; if(isset($_POST['Betreff']) && $_POST['Betreff'] == "Programmierung") { echo 'selected="selected"'; } echo' value="Programmierung"> Programmierung </option>
<option '; if(isset($_POST['Betreff']) && $_POST['Betreff'] == "Suchmaschienenoptimierung") { echo 'selected="selected"'; } echo' value="Suchmaschienenoptimierung"> Suchmaschienenoptimierung </option>
<option '; if(isset($_POST['Betreff']) && $_POST['Betreff'] == "Shop") { echo 'selected="selected"'; } echo' value="Shop"> Online-Shop </option>
</select></td>
<td class="Stil1" style="font-size:10px; color:red;">'; if(strlen($e0) > 2) { echo $e0; } echo '</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td style="border-style: none; border-width: medium" align="left">
<select name="Anrede" size="1">
<option '; if(!isset($_POST['Anrede'])) { echo 'selected="selected"'; } echo' value="0"> Anrede </option>
<option '; if(isset($_POST['Anrede']) && $_POST['Anrede'] == "Herr") { echo 'selected="selected"'; } echo' value="Herr"> Herr </option>
<option '; if(isset($_POST['Anrede']) && $_POST['Anrede'] == "Frau") { echo 'selected="selected"'; } echo' value="Frau"> Frau </option>
</select></td>
<td class="Stil1" style="font-size:10px; color:red;">'; if(strlen($e1) > 2) { echo $e1; } echo '</td>
</tr>
<tr>
<td style="border-style: none; border-width: medium" align="left">
<input size="40%" name="Vorname" class="Stil1" value="'; if(isset($_POST['Vorname']) && is_string($_POST['Vorname'])) { echo htmlspecialchars($_POST['Vorname']); } echo '" onFocus="if(this.value==\'Vorname\'){ this.value=\'\'; this.style.color=\'#000000\'}" onBlur="if(this.value==\'\'){this.value=\'Vorname\';this.style.color=\'#666666\'}" style="border:2px solid #666666; color: #666666; background-color:#FFFFFF" title="Vorname" />
<td> </td>
</tr>
<tr>
<td style="border-style: none; border-width: medium" align="left">
<input size="40%" name="Name" class="Stil1" value="'; if(isset($_POST['Name']) && is_string($_POST['Name'])) { echo htmlspecialchars($_POST['Name']); } echo '" onFocus="if(this.value==\'Name*\'){ this.value=\'\'; this.style.color=\'#000000\'}" onBlur="if(this.value==\'\'){this.value=\'Name*\';this.style.color=\'#666666\'}" style="border:2px solid #666666; color: #666666; background-color:#FFFFFF" title="Name" /></td>
<td class="Stil1" style="font-size:10px; color:red;">'; if(strlen($e2) > 2) { echo $e2; } echo '</td>
</tr>
<tr>
<td style="border-style: none; border-width: medium" align="left">
<input size="40%" name="Anschrift" class="Stil1" value="'; if(isset($_POST['Anschrift']) && is_string($_POST['Anschrift'])) { echo htmlspecialchars($_POST['Anschrift']); } echo '" onFocus="if(this.value==\'Anschrift\'){ this.value=\'\'; this.style.color=\'#000000\'}" onBlur="if(this.value==\'\'){this.value=\'Anschrift\';this.style.color=\'#666666\'}" style="border:2px solid #666666; color: #666666; background-color:#FFFFFF" title="Anschrift" /></td>
<td> </td>
</tr>
<tr>
<td style="border-style: none; border-width: medium" align="left">
<input size="7%" name="PLZ" class="Stil1" value="'; if(isset($_POST['PLZ']) && is_string($_POST['PLZ'])) { echo htmlspecialchars($_POST['PLZ']); } echo '" onFocus="if(this.value==\'PLZ\'){ this.value=\'\'; this.style.color=\'#000000\'}" onBlur="if(this.value==\'\'){this.value=\'PLZ\';this.style.color=\'#666666\'}" style="border:2px solid #666666; color: #666666; background-color:#FFFFFF" title="PLZ" />
<span> </span>
<input size="26%" name="Stadt" class="Stil1" value="'; if(isset($_POST['Stadt']) && is_string($_POST['Stadt'])) { echo htmlspecialchars($_POST['Stadt']); } echo '" onFocus="if(this.value==\'Stadt\'){ this.value=\'\'; this.style.color=\'#000000\'}" onBlur="if(this.value==\'\'){this.value=\'Stadt\';this.style.color=\'#666666\'}" style="border:2px solid #666666; color: #666666; background-color:#FFFFFF" title="Stadt" /></td>
</tr>
<tr>
<td style="border-style: none; border-width: medium" align="left">
<input size="40%" name="Telefon" class="Stil1" value="'; if(isset($_POST['Telefon']) && is_string($_POST['Telefon'])) { echo htmlspecialchars($_POST['Telefon']); } echo '" onFocus="if(this.value==\'Telefon*\'){ this.value=\'\'; this.style.color=\'#000000\'}" onBlur="if(this.value==\'\'){this.value=\'Telefon*\';this.style.color=\'#666666\'}" style="border:2px solid #666666; color: #666666; background-color:#FFFFFF" title="Telefon" /></td>
<td class="Stil1" style="font-size:10px; color:red;">'; if(strlen($e3) > 2) { echo $e3; } echo '</td>
</tr>
<tr>
<td style="border-style: none; border-width: medium" align="left">
<input size="40%" name="Email" class="Stil1" value="'; if(isset($_POST['Email']) && is_string($_POST['Email'])) { echo htmlspecialchars($_POST['Email']); } echo '" onFocus="if(this.value==\'Email*\'){ this.value=\'\'; this.style.color=\'#000000\'}" onBlur="if(this.value==\'\'){this.value=\'Email*\';this.style.color=\'#666666\'}" style="border:2px solid #666666; color: #666666; background-color:#FFFFFF" title="Email" /></td>
<td class="Stil1" style="font-size:10px; color:red;">'; if(strlen($e4) > 2) { echo $e4; } echo '</td>
</tr>
<tr>
<td style="border-style: none; border-width: medium">
<div align="left"><textarea rows="10" cols="39" name="Nachricht" class="Stil1" onFocus="if(this.value==\'Ihre Fragen / Nachricht*\'){ this.value=\'\'; this.style.color=\'#000000\'}" onBlur="if(this.value==\'\'){this.value=\'Ihre Fragen / Nachricht*\';this.style.color=\'#666666\'}" style="border:2px solid #666666; color: #666666; background-color:#FFFFFF; font-family:Verdana, Arial, Helvetica, sans-serifl; font-size:12px" title="Nachricht">'; if(isset($_POST['Nachricht']) && is_string($_POST['Nachricht'])) { echo htmlspecialchars($_POST['Nachricht']); } echo '</textarea></div>
</td>
<td valign="top" class="Stil1" style="font-size:10px; color:red;">'; if(strlen($e5) > 2) { echo $e5; } echo '</td>
</tr>
<tr>
<td style="border-style: none; border-width: medium" align="left">
<span class="Stil1" style="color:#FFFFFF; font-size:12px;"><strong>Spamschutz:</strong></span></td>
</tr>
<tr>
<td><img src="captcha/captcha.php" border="0" title="Sicherheitscode"> <input name="sicherheitscode" size="5%"></td>
<td class="Stil1" style="font-size:10px; color:red;">'; if(strlen($e6) > 2) { echo $e6; } echo '</td>
</tr>
</table>
<p class="Stil1 Stil14"><i>*Pflichtfelder</i></p>
<input name="submit" class="Stil1" type="submit" value="Abschicken" style="color: #000000; border: 2px solid #666666; background-color: #FF0000" /> <input class="Stil1" type="reset" value="Eingaben löschen" style="color: #000000; border: 2px solid #666666; background-color: #FFFFFF" />
</form>
<br /><br />
</div>
'; }
else {
$mail = '';
mail('info@siba-webdesign.com','Kontaktforumular', $mail);
echo 'alles richtig';
}}
?>
1. $mail ist mit Absicht noch nicht definiert, aber ist auch unwichtig, da dieses else nicht aufgerufen wird
( wegen dem Fehler )
2. Die Session wird in der index datei der homepage schon geöffnet, diese datei wird ledeglich included
Hier nochmal der Code den ich von der Website genommen habe:
Code:
<?php
session_start();
unset($_SESSION['captcha_spam']);
function randomString($len) {
function make_seed(){
list($usec , $sec) = explode (' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
srand(make_seed());
//Der String $possible enthält alle Zeichen, die verwendet werden sollen
$possible="0123456789";
$str="";
while(strlen($str)<$len) {
$str.=substr($possible,(rand()%(strlen($possible))),1);
}
return($str);
}
$text = randomString(5); //Die Zahl bestimmt die Anzahl stellen
$_SESSION['captcha_spam'] = $text;
header('Content-type: image/png');
$img = ImageCreateFromPNG('captcha.PNG'); //Backgroundimage
$color = ImageColorAllocate($img, 0, 0, 0); //Farbe
$ttf = $_SERVER['DOCUMENT_ROOT']."/captcha/XFILES.TTF"; //Schriftart
$ttfsize = 25; //Schriftgrösse
$angle = rand(0,5);
$t_x = rand(5,30);
$t_y = 35;
imagettftext($img, $ttfsize, $angle, $t_x, $t_y, $color, $ttf, $text);
imagepng($img);
imagedestroy($img);
?>
danke im vorraus für die Hilfe
mfg, Caltoriz