Ersteinmal Hallo!
Ich bin schon am verzweifeln. Ich habe ein Kontaktformular entworfen und wollte es mit dem Rechen-Chapta schützen.
kontaktformular.php
<html>
<head>
<meta http-equiv="Content-Language" content="de">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Kontaktformular</title>
</head>
<body>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"><u><font face="Georgia" size="6" color="#FF0000">
Kontaktformular</font></u></p>
<p align="center"> </p>
<form action="kontaktformular-auswerten.php">
<table border="0" width="382" id="kontakt" align="center">
<tr>
<td width="112">
<p align="right">Name: </td>
<td width="260">
<!--webbot bot="Validation" s-data-type="String" b-allow-letters="TRUE" b-allow-whitespace="TRUE" --><input type="text" name="kelsdfsdgb654" size="36"></td>
</tr>
<tr>
<td width="112">
<p align="right">Telefonnummer: </td>
<td width="260">
<!--webbot bot="Validation" s-data-type="Integer" s-number-separators="x" --><input type="text" name="Telefon" size="36"></td>
</tr>
<tr>
<td height="28" width="112">
<p align="right">E-Mail Adresse: </td>
<td width="260" height="28"><input type="text" name="Mail" size="36"></td>
</tr>
<tr>
<td width="112">
<p align="right">Betreff: </td>
<td width="260"><input type="text" name="Betreff" size="36"></td>
</tr>
<tr>
<td width="112">
<p align="right">Mitteilung: </td>
<td width="260"><textarea rows="7" name="Text" cols="27"></textarea></td>
</tr>
<tr>
<td><img src="rechen-captcha.php"></td>
<td><input type="text" name="sicherheitscode" size="5"></td>
</tr>
<tr>
<td width="112"> </td>
<td width="260"> </td>
</tr>
<tr>
<td width="112"> </td>
<td width="260"> <input type="submit" name="Send" value="Absenden"></td>
</tr>
</table>
<p align="center"> </p>
</form>
<p align="center"> </p>
</body>
</html>
kontakrformular-auswerten.php
<html>
<head>
<title>Kontaktformular mit PHP</title>
</head>
<body>
<?php
function encrypt($string, $key) {
$result = '';
for($i=0; $i<strlen($string); $i++) {
$char = substr($string, $i, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)+ord($keychar));
$result.=$char;
}
return base64_encode($result);
}
$sicherheits_eingabe = encrypt($_POST["sicherheitscode"], "29jfkd921");
$sicherheits_eingabe = str_replace("=", "", $sicherheits_eingabe);
if(isset($_SESSION['rechen_captcha_spam']) AND $sicherheits_eingabe == $_SESSION['rechen_captcha_spam'] AND is_numeric($_POST["sicherheitscode"]) == true AND $sicherheits_eingabe == true){
unset($_SESSION['rechen_captcha_spam']);
if($_REQUEST['Send'])
{
if(empty($_REQUEST['Name']) || empty($_REQUEST['Email']) && empty($_REQUEST['Telefon']) || empty($_REQUEST['Betreff']) || empty($_REQUEST['Mail']) || empty($_REQUEST['Text']))
{
echo"Bitte gehen Sie <a href=\"javascript:history.back();\">zurück</a> und füllen Sie alle Felder aus!";
}
else
{
$Mailnachricht = "Onlineformular: \n\n";
$Mailnachricht .= "Name: ";
$Mailnachricht .= $_POST['kelsdfsdgb654'];
$Mailnachricht .= "\nTel.: ";
$Mailnachricht .= $_POST['Telefon'];
$Mailnachricht .= "\nE-Mail.: ";
$Mailnachricht .= $_POST['Mail'];
$Mailnachricht .= "\n\nBetreff: ";
$Mailnachricht .= $_POST['Betreff'];
$Mailnachricht .= "\n\nMitteilung: ";
$Mailnachricht .= $_POST['Text'];
$Mailnachricht .= "\n\nAusgefüllt am: ";
$Mailnachricht .= date("d.m.Y H:i:s");
$Mailbetreff = "Kontaktformular: ";
$Mailbetreff .= $_POST['Betreff'];
mail('schopp@gmx.at', $Mailbetreff, $Mailnachricht, "From: ".$_REQUEST['Mail']);
}
}
}
else{
die ("Der Sicherheitscode ist falsch!");
}
?>
</body>
</html>
rechen-chapta.php
<?php
session_start();
unset($_SESSION['rechen_captcha_spam']);
$zahl1 = rand(10,20); //Erste Zahl 10-20
$zahl2 = rand(1,10); //Zweite Zahl 1-10
$operator = rand(1,2); // + oder -
if($operator == "1"){
$operatorzeichen = " + ";
$ergebnis = $zahl1 + $zahl2;
}else{
$operatorzeichen = " - ";
$ergebnis = $zahl1 - $zahl2;
}
function encrypt($string, $key) {
$result = '';
for($i=0; $i<strlen($string); $i++) {
$char = substr($string, $i, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)+ord($keychar));
$result.=$char;
}
return base64_encode($result);
}
$_SESSION['rechen_captcha_spam'] = encrypt($ergebnis, "29jfkd921"); //Key
$_SESSION['rechen_captcha_spam'] = str_replace("=", "", $_SESSION['rechen_captcha_spam']);
$rechnung = $zahl1.$operatorzeichen.$zahl2." = ?";
$img = imagecreatetruecolor(80,15);
$schriftfarbe = imagecolorallocate($img,13,28,91);
$hintergrund = imagecolorallocate($img,162,162,162);
imagefill($img,0,0,$hintergrund);
imagestring($img, 3, 2, 0, $rechnung, $schriftfarbe);
header("Content-type: image/png");
imagepng($img);
imagedestroy($img);
?>
Zusammenfassung:
Wenn ich das Kontaktformular öffne sehe ich das Chapta nicht. Wenn man die rechen-chapta.php direkt aufruft kommen session[]-Fehler.
Falls ihr euch das Projekt online ansehen wollt: www.transporte-scheiner.at/kontakttest/dateiname.php
Hoffe ihr könnt mir Helfen
