Mein Problemm ist das ich ein Regsitrationsfomular schreibe das die einzelnen Werte überprüfen soll! Das klappt alles bis zu der Stelle wo der Captcha code überprüft werden soll.
Hatte mir von stoppt-den-spam.info das captcha script genommen und eingebaut! Leider funzt es nicht.
Wenn ich es blank lasse also das Script nicht einbaue und so probiere läuft es. Dabei dachte ich das die sessions nicht übernommen werden was ich denke auch so ist. Würde gerne aber wissen wie ich es beheben kann^^
Hier mal die Quellcodes der 3 dateien
reg.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Registration</title> </head> <link href="style.css" rel="stylesheet" type="text/css" /> <body> <h3>Registrierung</h3> <form action="reg2.php" method="post"> <table> <tr> <td>Benutzername: </td> <td><input type="text" maxlength="15" name="bn" /></td> </tr> <tr> <td>Password: </td> <td><input type="password" maxlength="15" name="pw1" /></td> </tr> <tr> <td>Password Wiederholen: </td> <td><input type="password" maxlength="15" name="pw2" /></td> </tr> <tr> <td>E-Mail Adresse: </td> <td><input type="text" maxlength="20" name="ea" /></td> </tr> <tr> <tr> <td><img src="captcha.php" border="0" title="Sicherheitscode"></td> <td><input type="text" name="sicherheitscode" size="5"></td> </tr> <td></td> <td><input type="submit" value="Senden" /></td> </tr> </table> </form> </body> </html>
captcha.php
<?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="ABCDEFGHJKLMNPRSTUVWXYZabcdefghijkmnpqrstuvwxy z23456789"; $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 = "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); ?>
reg2.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Bball-Manager</title> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="header"></div> <div id="navi"> <div id="b" style="padding-left:3px;"><a href="index.php?site=home"><img src="Bilder/b1.jpg" border="0"/></a></div> <div id="b"><img src="Bilder/b2.jpg" width="149" height="28" border="0" /></div> <div id="b"><img src="Bilder/b3.jpg" width="149" height="28" border="0" /></div> <div id="b"><img src="Bilder/b4.jpg" width="149" height="28" border="0" /></div> <div id="b"><a href="index.php?site=reg"><img src="Bilder/b5.jpg" width="149" height="28" border="0" /></a></div> </div> <div id="contentpuffer" class="clear"> <table width="750px" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="20px"> </td> <td width="160px"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="20px"> </td> </tr> <tr> <td height="20px"></td> </tr> <tr> <td height="20px"></td> </tr> <tr> <td height="20px"></td> </tr> <tr> <td height="20px"></td> </tr> <tr> <td height="20px"></td> </tr> </table> </td> <td width="20px"> </td> <td width="20px"> </td> <td width="510px"> <style type="text/css"> <!-- body{ color: #FFFFFF; } .style1 { font-size: 16px; font-weight: bold; font-color: #FFFFFF; } .style2 { font-size: 14px; font-color: #FFFFFF; } --> </style> </head> <body> <?php $bn = $_POST[bn]; $pw1 = $_POST[pw1]; $pw2 = $_POST[pw2]; $ea = $_POST[ea]; if (empty($bn) || strlen($bn) < 4 || !preg_match("/^[a-z0-9]*$/i", $bn)) { echo "Bitte geben Sie einen <font color='red'>Benutzernamen</font> ein!<br> <a href='java script:history.back()'>Zurück</a> "; } elseif (empty($pw1) || empty($pw2) || strlen($bn) < 4) { echo "Bitte geben Sie ein <font color='red'>Passwort</font> ein!<br> <a href='java script:history.back()'>Zurück</a> "; } elseif ($pw1 != $pw2) { echo "Die eingegeben <font color='red'>Passwörter müssen übereinstimmen!</font><br> <a href='java script:history.back()'>Zurück</a> "; } elseif (empty($ea) || !stristr($ea, '@')) { echo "Bitte geben Sie eine <font color='red'>E-Mail Adresse</font> ein! <a href='java script:history.back()'>Zurück</a> "; } elseif (!isset($_SESSION['captcha_spam']) || $_POST["sicherheitscode"] != $_SESSION['captcha_spam']) { echo "Der Captcha Code wurde falsch eingetippt. Bitte nochmal versuchen!<br> <a href='java script:history.back()'>Zurück</a> "; } else { unset($_SESSION['captcha_spam']); echo "$bn " . "Sie wurden erfolgreich registriert!<br>"; echo "Die Aktivierungsmail wurde an " . "$ea " . "versand.<br>"; } ?> </td> <td width="20"> </td> </tr> </table> </body> </html> </td> <td width="20px"> </td> </tr> </table> <div id="footer"></div> </div> </body> </html>
Hoffentlich könnt ihr mir helfen!
Danke in vorraus
MFG
Neverball
edit:// Habs hinbekommen musste nur im header von reg2.php noch session_name() hinzufügen^^
Dieser Beitrag wurde von Neverball bearbeitet: 26. März 2009 - 17:31