Hilfe zu "Zahlen-Captcha" in NOF-Formular

Hier werden Probleme rund um das Zahlen Captcha behandelt

Moderator: frameguard

Hilfe zu "Zahlen-Captcha" in NOF-Formular

Beitragvon bitmover » 29.05.2007, 18:36

Hallo ins Forum,

mir geht es ähnlich wie vielen anderen Anwendern hier im Forum:
1. ich bin relativ frisch auf der html-/php-Schiene unterwegs
2. ich bekomme das captcha-Script nicht richtig eingebunden bzw. das Formular nicht 100%ig zum Fliegen

Nach Einbinden des Scripts ist es möglich, das Formular !ohne irgendeine Eingabe! - einschließlich eines (evtl. auch falschen) CAPTCHA-Codes - zu versenden. Bevor das Script eingebunden wurde, wurden zumindest die *- (Pflicht-)Felder geprüft.

Der Code der Seite sieht wie folgt aus:
____________________
Code: Alles auswählen
<?php session_start(); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>captcha-Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript">
<!--
document.write("<SCRIPT SRC=\"./assets/validation.js\"><\/SCRIPT>");
//-->
</script>
<link rel="stylesheet" type="text/css" href="./html/style.css">
<link rel="stylesheet" type="text/css" href="./html/site.css">
</head>
<body style="margin: 0px;">
<table cellpadding="0" cellspacing="0" border="0" width="889">
  <tr valign="top" align="left">
   <td>
    <table border="0" cellspacing="0" cellpadding="0" width="274">
     <tr valign="top" align="left">
      <td width="118" height="484"><img src="./assets/images/autogen/clearpixel.gif" width="118" height="1" border="0" alt=""></td>
      <td width="156"><img src="./assets/images/autogen/clearpixel.gif" width="156" height="1" border="0" alt=""></td>
     </tr>
     <tr valign="top" align="left">
      <td></td>
      <td width="156" class="TextObject">
      <p align="left"><font color="#004682">
      <?php
         $a1 = array("Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember");
         $d1 = date("j");
         $d2 = date("n")-1;
         $d3 = date("Y");
         $dday = "$d1. $a1[$d2] $d3";

         echo $dday;
      ?>
      </p>
       <p>&nbsp;</p>
      </td>
     </tr>
    </table>
   </td>
   <td>
    <table border="0" cellspacing="0" cellpadding="0" width="518">
     <tr valign="top" align="left">
      <td width="101" height="77"><img src="./assets/images/autogen/clearpixel.gif" width="101" height="1" border="0" alt=""></td>
      <td width="417"><img src="./assets/images/autogen/clearpixel.gif" width="417" height="1" border="0" alt=""></td>
     </tr>
     <tr valign="top" align="left">
      <td></td>
      <td width="417" class="TextObject">
       <p style="text-align: left;"><b><span style="font-family: Arial,Helvetica,Geneva,Sans-serif; font-size: 16pt; color: rgb(0,70,130);">Kontaktformular mit “CAPTCHA”</span></b></p>
      </td>
     </tr>
    </table>
    <table cellpadding="0" cellspacing="0" border="0" width="615">
     <tr valign="top" align="left">
      <td>
       <table border="0" cellspacing="0" cellpadding="0" width="130">
        <tr valign="top" align="left">
         <td width="7" height="20"><img src="./assets/images/autogen/clearpixel.gif" width="7" height="1" border="0" alt=""></td>
         <td width="12"><img src="./assets/images/autogen/clearpixel.gif" width="12" height="1" border="0" alt=""></td>
         <td width="110"><img src="./assets/images/autogen/clearpixel.gif" width="110" height="1" border="0" alt=""></td>
         <td width="1"><img src="./assets/images/autogen/clearpixel.gif" width="1" height="1" border="0" alt=""></td>
        </tr>
        <tr valign="top" align="left">
         <td colspan="2"></td>
         <td colspan="2" width="111" class="TextObject">
          <p style="text-align: right;"><span style="font-family: Arial,Helvetica,Geneva,Sans-serif; font-size: 10pt;">* Anrede</span></p>
          <p style="text-align: right;"><span style="font-family: Arial,Helvetica,Geneva,Sans-serif; font-size: 10pt;">* Name</span></p>
          <p style="text-align: right;"><span style="font-family: Arial,Helvetica,Geneva,Sans-serif; font-size: 10pt;">Vorname</span></p>
          <p style="text-align: right;"><span style="font-family: Arial,Helvetica,Geneva,Sans-serif; font-size: 10pt;">Anschrift</span></p>
          <p style="text-align: right;"><span style="font-family: Arial,Helvetica,Geneva,Sans-serif; font-size: 10pt;">* PLZ / * Ort</span></p>
          <p style="text-align: right;"><span style="font-family: Arial,Helvetica,Geneva,Sans-serif; font-size: 10pt;">* E-Mail</span></p>
          <p style="text-align: right;"><span style="font-family: Arial,Helvetica,Geneva,Sans-serif; font-size: 10pt;">Nachricht</span></p>
         </td>
        </tr>
        <tr valign="top" align="left">
         <td colspan="4" height="97"></td>
        </tr>
        <tr valign="top" align="left">
         <td></td>
         <td colspan="2" width="122" class="TextObject">
          <p style="text-align: right;"><span style="font-family: Arial,Helvetica,Geneva,Sans-serif; font-size: 9pt;"><span style="font-size: 8pt;"><b>SPAM-Schutz! -<br>bitte Code eingeben:</b><br></span><span style="font-size: 7pt;">(Groß- und Kleinschreibung beachten!)</span></span></p>
         </td>
         <td></td>
        </tr>
       </table>
      </td>
      <td>
       <table border="0" cellspacing="0" cellpadding="0" width="485">
        <tr valign="top" align="left">
         <td width="7" height="20"><img src="./assets/images/autogen/clearpixel.gif" width="7" height="1" border="0" alt=""></td>
         <td></td>
        </tr>
        <tr valign="top" align="left">
         <td height="362"></td>
         <td width="478">
          <?php
          /* Beginn "CAPTCHA-PRÜFUNG" */
          if(isset($_SESSION['captcha_spam']) AND $_POST["Sicherheitscode"] == $_SESSION['captcha_spam'])
          {
          unset($_SESSION['captcha_spam']);
          }
          /* Ende "CAPTCHA-PRÜFUNG" */
          ?>
          <script type="text/javascript">
          <!--
          function __fv1_ContactForm(form) {
           var args = {
          "adrt":[["NOF_isRequired", [''], "- für das Feld 'Anrede' ist eine Auswahl erforderlich.", "", ""]],
          "name":[["NOF_isRequired", [''], "- für das Feld 'Name' ist eine Eingabe erforderlich.", "", ""]],
          "plz":[["NOF_isRequired", [''], "- für das Feld 'PLZ' ist eine Eingabe erforderlich.", "", ""], ["NOF_isLengthInRange", ['5', '5'], "- bitte prüfen Sie die Postleitzahl.", "", ""]],
          "home":[["NOF_isRequired", [''], "- für das Feld 'Ort' ist eine Eingabe erforderlich.", "", ""]],
          "e-mail":[["NOF_isRequired", [''], "- für das Feld 'E-Mail' ist eine Eingabe erforderlich.", "", ""], ["NOF_isEmailAddress", [''], "- bitte prüfen Sie die Eingabe Ihrer E-Mail-Adresse.", "", ""]]
          "Sicherheitscode":[["NOF_isRequired", [''], "Dieses Feld ist erforderlich.", "", ""]]
           };
           return NOF_validateForm(form, args, true, null,'Bitte beachten Sie den/die folgende(n) Hinweis(e):');
          }
          //-->
          </script>
          <form name="ContactForm" enctype="multipart/form-data" action="./scripts/FormHandler.php" method="POST" onSubmit="return __fv1_ContactForm(this)">
           <input type=hidden name="_nof_param_file" value="FormInfoContactForm.XML">
           <table border="0" cellspacing="0" cellpadding="0" width="61">
            <tr valign="top" align="left">
             <td height="24" width="61">
              <select id="FormsComboBox2" name="adrt" tabindex="1">
               <option value=""> </option>
               <option value="Frau">Frau</option>
               <option value="Herr">Herr</option>
               <option value="Firma">Firma</option>
              </select>
             </td>
            </tr>
           </table>
           <table border="0" cellspacing="0" cellpadding="0" width="472">
            <tr valign="top" align="left">
             <td height="4"></td>
            </tr>
            <tr valign="top" align="left">
             <td height="19" width="472"><input id="FormsEditField1" type="text" name="name" tabindex="2" style="white-space: pre;" value="" size="59" maxlength="59"></td>
            </tr>
           </table>
           <table border="0" cellspacing="0" cellpadding="0" width="472">
            <tr valign="top" align="left">
             <td height="9"></td>
            </tr>
            <tr valign="top" align="left">
             <td height="19" width="472"><input id="FormsEditField2" type="text" name="pren" tabindex="9" style="white-space:pre" value="" size="59" maxlength="59"></td>
            </tr>
           </table>
           <table border="0" cellspacing="0" cellpadding="0" width="472">
            <tr valign="top" align="left">
             <td height="8"></td>
            </tr>
            <tr valign="top" align="left">
             <td height="19" width="472"><input id="FormsEditField3" type="text" name="addr" tabindex="10" style="white-space:pre" value="" size="59" maxlength="59"></td>
            </tr>
           </table>
           <table border="0" cellspacing="0" cellpadding="0" width="433">
            <tr valign="top" align="left">
             <td height="9"></td>
             <td width="9"><img src="./assets/images/autogen/clearpixel.gif" width="9" height="1" border="0" alt=""></td>
             <td></td>
            </tr>
            <tr valign="top" align="left">
             <td height="19" width="40"><input id="FormsEditField5" type="text" name="plz" tabindex="3" style="white-space:pre" value="" size="5" maxlength="52"></td>
             <td></td>
             <td width="384"><input id="FormsEditField6" type="text" name="home" tabindex="4" style="white-space:pre" value="" size="48" maxlength="48"></td>
            </tr>
           </table>
           <table border="0" cellspacing="0" cellpadding="0" width="472">
            <tr valign="top" align="left">
             <td height="9"></td>
            </tr>
            <tr valign="top" align="left">
             <td height="19" width="472"><input id="FormsEditField4" type="text" name="e-mail" tabindex="5" style="white-space:pre" value="" size="59" maxlength="59"></td>
            </tr>
           </table>
           <table border="0" cellspacing="0" cellpadding="0" width="353">
            <tr valign="top" align="left">
             <td height="9"></td>
            </tr>
            <tr valign="top" align="left">
             <td height="84" width="353"><textarea id="FormsMultiLine1" name="mssg" tabindex="6" style="white-space:pre" rows="6" cols="42"></textarea></td>
            </tr>
           </table>
           <table cellpadding="0" cellspacing="0" border="0" width="379">
            <tr valign="top" align="left">
             <td>
              <table cellpadding="0" cellspacing="0" border="0" width="217">
               <tr valign="top" align="left">
                <td>
                 <table border="0" cellspacing="0" cellpadding="0" width="140">
                  <tr valign="top" align="left">
                   <td height="9"></td>
                  </tr>
                  <tr valign="top" align="left">
                   <td height="40" width="140"><img src="./captcha/captcha.php" border="0" title="Sicherheitscode">
                   </td>
                  </tr>
                 </table>
                </td>
                <td>
                 <table border="0" cellspacing="0" cellpadding="0" width="77">
                  <tr valign="top" align="left">
                   <td width="1" height="20"><img src="./assets/images/autogen/clearpixel.gif" width="1" height="1" border="0" alt=""></td>
                   <td width="76"><img src="./assets/images/autogen/clearpixel.gif" width="76" height="1" border="0" alt=""></td>
                  </tr>
                  <tr valign="top" align="left">
                   <td></td>
                   <td width="76" class="TextObject">
                    <p style="text-align: center;"><b><span style="font-size: 14pt; color: rgb(0,70,130);">&gt; &gt; &gt;</span></b></p>
                   </td>
                  </tr>
                 </table>
                </td>
               </tr>
              </table>
              <table border="0" cellspacing="0" cellpadding="0" width="183">
               <tr valign="top" align="left">
                <td height="38"></td>
               </tr>
               <tr valign="top" align="left">
                <td height="24" width="183"><input type="reset" name="erase" tabindex="8" class="nof_form_input_reset" value="Eingabe(n) löschen" id="FormsButton1"></td>
               </tr>
              </table>
             </td>
             <td>
              <table border="0" cellspacing="0" cellpadding="0" width="162">
               <tr valign="top" align="left">
                <td width="2" height="26"><img src="./assets/images/autogen/clearpixel.gif" width="2" height="1" border="0" alt=""></td>
                <td width="126"><img src="./assets/images/autogen/clearpixel.gif" width="126" height="1" border="0" alt=""></td>
                <td width="34"><img src="./assets/images/autogen/clearpixel.gif" width="34" height="1" border="0" alt=""></td>
               </tr>
               <tr valign="top" align="left">
                <td height="19" colspan="2" width="128"><input id="FormsEditField7" type="text" name="Sicherheitscode" style="white-space:pre" value="" size="16" maxlength="17"></td>
                <td></td>
               </tr>
               <tr valign="top" align="left">
                <td colspan="3" height="42"></td>
               </tr>
               <tr valign="top" align="left">
                <td height="24"></td>
                <td colspan="2" width="160"><input type="submit" name="send" tabindex="7" value="Formular senden" id="FormsButton2"></td>
               </tr>
              </table>
             </td>
            </tr>
           </table>
          </form>
         </td>
        </tr>
       </table>
      </td>
     </tr>
    </table>
   </td>
  </tr>
</table>
</body>
</html>

____________________


Wo liegt hier mein Fehler?

Ich freue mich über jede Hilfestellung.

Hierfür schon jetzt vielen Dank!
Zuletzt geändert von bitmover am 28.06.2007, 21:42, insgesamt 1-mal geändert.
bitmover
 
Beiträge: 1
Registriert: 29.05.2007, 17:21

Beitragvon frameguard » 11.06.2007, 18:15

Der Fehler liegt hier:

Code: Alles auswählen
     /* Beginn "CAPTCHA-PRÜFUNG" */
          if(isset($_SESSION['captcha_spam']) AND $_POST["Sicherheitscode"] == $_SESSION['captcha_spam'])
          {
          unset($_SESSION['captcha_spam']);
          }
          /* Ende "CAPTCHA-PRÜFUNG" */
          ?>


Du schließt das IF nach dem unset(); mit } ab. Diese schließende Klammer gehört aber ans Ende des GESAMTEN Scripts, denn der restliche Script soll ja nur dann abgearbeitet werden, wenn der Captcha-Code korrekt war.

Oder Du fügst nach } ein
ELSE {
die('Sicherheitscode falsch');
}
ein, das geht auch.
frameguard
 
Beiträge: 120
Registriert: 05.03.2007, 19:19
Wohnort: Wien


Zurück zu Zahlen Captcha

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 0 Gäste

cron