if Anweisung

weit2

Grünschnabel
Hallo:)
Ich wollt mal fragen ob mir jemand erklären kann wich ich zu diesem Formular eine if Anweisung schreiben kann.


Formular
Ich hab noch mal das Formular überarbeitet vom 07.09.2007 um 2.13 uhr
PHP:
<form id="w-registeren" name="w-registeren" method="POST" action=""><table width="100%" border="0" cellpadding="0" cellspacing="0" >
          <!--DWLayoutTable-->
          <tr>
            <td height="25" colspan="3" valign="middle"><strong class="Stil1">Pers&ouml;nliche Daten</strong></td>
                        <td width="141">&nbsp;</td>
                        <td width="25">&nbsp;</td>
                        <td width="57">&nbsp;</td>
                  <td width="123">&nbsp;</td>
                  <td width="57">&nbsp;</td>
                  <td width="15"></td>
                </tr>
          <tr>
            <td width="10" height="2"></td>
            <td colspan="3" rowspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#F5F5F5">
                      <!--DWLayoutTable-->
                      <tr>
                        <td height="25" colspan="3" align="right" valign="middle">Anrede:</td>
                        <td width="6" rowspan="4" valign="top"><img src="../bilder/standart/1px.png" width="1" height="1" /></td>
                        <td colspan="4" valign="middle">
                          <select name="anrede" size="1" class="spalte2" id="anrede" value="<?php echo $_POST['anrede'];?>" onfocus="ShowQuickTipp(this)" onblur="ShowQuickTipp('default')" >
                            <option value="">----- Bitte w&auml;hlen -----</option>
                            <option value="M" >Herr</option>
                            <option value="W" >Frau</option>
                                              </select></td>
                      </tr>
                      <tr>
                        <td height="25" colspan="3" align="right" valign="middle">Vorname:</td>
                        <td colspan="4" valign="middle"><label>
                          <input name="vorname" type="text" class="spalte2" id="vorname" maxlength="30" value="<?php echo $_POST['vorname'];?>" onfocus="ShowQuickTipp(this)" onblur="ShowQuickTipp('default')" />
                        </label></td>
                      </tr>
                      <tr>
                        <td height="25" colspan="3" align="right" valign="middle">Nachname:</td>
                        <td colspan="4" valign="middle">
                          <input name="nachname" type="text" class="spalte2" id="nachname" maxlength="30" value="<?php echo $_POST['nachname'];?>" onfocus="ShowQuickTipp(this)" onblur="ShowQuickTipp('default')" /></td>
                      </tr>
                      <tr>
                        <td height="25" colspan="3" align="right" valign="middle">Geburtsdatum:</td>
                        <td colspan="2" valign="middle"><label>
                          <select name="geburtstag" size="1" class="spalte5" id="geburtsdatum" value="<?php echo $_POST['geburts-tag'];?>"onfocus="ShowQuickTipp(this)" onblur="ShowQuickTipp('default')" >
                            <option value="  " >00</option>
                            <option value="01" >01</option>
                            <option value="02" >02</option>
                            <option value="03" >03</option>
                            <option value="04" >04</option>
                            <option value="05" >05</option>
                            <option value="06" >06</option>
                            <option value="07" >07</option>
                            <option value="08" >08</option>
                            <option value="09" >09</option>
                            <option value="10" >10</option>
                            <option value="11" >11</option>
                            <option value="12" >12</option>
                            <option value="13" >13</option>
                            <option value="14" >14</option>
                            <option value="15" >15</option>
                            <option value="16" >16</option>
                            <option value="17" >17</option>
                            <option value="18" >18</option>
                            <option value="19" >19</option>
                            <option value="20" >20</option>
                            <option value="21" >21</option>
                            <option value="22" >22</option>
                            <option value="23" >23</option>
                            <option value="24" >24</option>
                            <option value="25" >25</option>
                            <option value="26" >26</option>
                            <option value="27" >27</option>
                            <option value="28" >28</option>
                            <option value="29" >29</option>
                            <option value="30" >30</option>
                            <option value="31" >31</option>
                          </select>
                        .</label></td>
                        <td width="51" valign="middle"><label>
                          <select name="geburtsmonat" size="1" class="spalte5" id="select"value="<?php echo $_POST['geburtsmonat'];?>" onfocus="ShowQuickTipp(this)" onblur="ShowQuickTipp('default')" >
                            <option value="  " >00</option>
                            <option value="01" >01</option>
                            <option value="02" >02</option>
                            <option value="03" >03</option>
                            <option value="04" >04</option>
                            <option value="05" >05</option>
                            <option value="06" >06</option>
                            <option value="07" >07</option>
                            <option value="08" >08</option>
                            <option value="09" >09</option>
                            <option value="10" >10</option>
                            <option value="11" >11</option>
                            <option value="12" >12</option>
                          </select>                        
                        .</label></td>
                        <td width="85" valign="middle"><label>
                          <input name="geburtsjahr" type="text" class="spalte6" id="geburtsdatum" maxlength="4" value="<?php echo $_POST['geburtsjahr'];?>"onfocus="ShowQuickTipp(this)" onblur="ShowQuickTipp('default')" />
                        </label></td>
                      </tr>
                      <tr>
                        <td height="4" colspan="8" valign="top" bgcolor="#FFFFFF"><img src="../bilder/standart/1px.png" width="1" height="1" /></td>
                      </tr>
                      <tr>
                        <td height="25" colspan="3" align="right" valign="middle">Land:</td>
                        <td rowspan="4" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
                        <td colspan="4" valign="middle">
                          <select name="land" size="1" class="spalte2" id="land" value="<?php echo $_POST['land'];?>" onfocus="ShowQuickTipp(this)" onblur="ShowQuickTipp('default')" >
                            <option value="" selected="selected">----- Bitte w&auml;hlen -----</option>
                            <option value="DE" >Deutschland</option>
                            <option value="AT" >&Ouml;sterreich</option>
                            <option value="CH" >Schweiz</option>
                        </select>						</td>
                      </tr>
                      <tr>
                        <td height="25" colspan="3" align="right" valign="middle">Stra&szlig;e Hausnummer:</td>
                        <td colspan="4" valign="middle"><label>
                          <input name="strasse" type="text" class="spalte2" id="strasse" maxlength="30" value="<?php echo $_POST['strsse'];?>"onfocus="ShowQuickTipp(this)" onblur="ShowQuickTipp('default')"  />
                        </label></td>
                      </tr>
                      <tr>
                        <td height="25" colspan="3" align="right" valign="middle">Postleitzahl Ort:</td>
                        <td width="44" valign="middle"><label>
                          <input name="plz" type="text" class="spalte3" id="plz-ort" maxlength="10" value="<?php echo $_POST['plz'];?>"onfocus="ShowQuickTipp(this)" onblur="ShowQuickTipp('default')"  />
                        </label></td>
                          <td colspan="3" valign="middle"><label>
                          <input name="ort" type="text" class="spalte4" id="plz-ort" maxlength="30"value="<?php echo $_POST['ort'];?>"onfocus="ShowQuickTipp(this)" onblur="ShowQuickTipp('default')"  />
                          </label></td>
                      </tr>
                      <tr>
                        <td height="25" colspan="3" align="right" valign="middle">E-mail:</td>
                        <td colspan="4" valign="middle"><label>
                          <input name="email" type="text" class="spalte2" id="email" maxlength="30" value="<?php echo $_POST['email'];?>"onfocus="ShowQuickTipp(this)" onblur="ShowQuickTipp('default')"/>
                        </label></td>
                      </tr>
                      <tr>
                        <td width="25" height="25" align="center" valign="middle"><label>
                          <input name="agb" type="checkbox" id="agb" value="agb" />
                        </label></td>
                        <td width="5">&nbsp;</td>
                        <td colspan="6" valign="middle">ich akzeptiere die<a href="agb/agb.html" target="_blank" class="Stil5" onclick="window.open('agb/agb.html','mailagb','width=640,height=800,left=100,top=100,resizable=no,scrollbars=yes'); return false;"> AGB</a></td>
                      </tr>
                      <tr>
                        <td height="0"></td>
                        <td></td>
                        <td width="131"></td>
                        <td></td>
                        <td></td>
                        <td width="9"></td>
                        <td></td>
                        <td></td>
                      </tr>
                      

              
                  </table></td>
                        <td rowspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#F5F5F5">
                          <!--DWLayoutTable-->
                          <tr>
                            <td width="25" height="25" align="center" valign="middle"><?php echo $error['anredebild'];?></td>
                          </tr>
                          <tr>
                            <td height="25" align="center" valign="middle"><?php echo $error['vornamebild'];?></td>
                          </tr>
                          <tr>
                            <td height="25" align="center" valign="middle"><?php echo $error['nachnamebild'];?></td>
                          </tr>
                          <tr>
                            <td height="25" align="center" valign="middle"><?php echo $error['geburtstagbild'];echo $error['geburtsmonatbild'];echo $error['geburtsjahrbild'];?></td>
                          </tr>
                          <tr>
                            <td height="4" valign="top" bgcolor="#FFFFFF"><img src="../bilder/standart/1px.png" width="1" height="1" /></td>
                          </tr>
                          <tr>
                            <td height="25" align="center" valign="middle"><?php echo $error['landbild'];?></td>
                          </tr>
                          <tr>
                            <td height="25" align="center" valign="middle"><?php echo $error['strassebild'];?></td>
                          </tr>
                          <tr>
                            <td height="25" align="center" valign="middle"><?php echo $error['plzbild']; echo $error['ortbild'];?></td>
                          </tr>
                          <tr>
                            <td height="25" align="center" valign="middle"><?php echo $error['emailbild'];?></td>
                          </tr>
                          <tr>
                            <td height="25" align="center" valign="middle"><?php echo $error['agbbild'];?></td>
                          </tr>
                          
                          
                          
                        </table></td>
                        <td></td>
                  <td></td>
                  <td></td>
                  <td></td>
          </tr>
          <tr>
            <td height="227"></td>
            <td></td>
            <td colspan="2" rowspan="3" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FF9900">
                      <!--DWLayoutTable-->
                      <tr>
                        <td width="1" height="1"></td>
                        <td width="79"></td>
                        <td width="30"></td>
                        <td width="68"></td>
                        <td width="2"></td>
                      </tr>
                      <tr>
                        <td height="15"></td>
                        <td colspan="3" rowspan="3" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#F5F5F5">
                            <!--DWLayoutTable-->
                            <tr>
                              <td width="9" height="9"></td>
                              <td width="159"></td>
                              <td width="9"></td>
                            </tr>
                            <tr>
                              <td height="260"></td>
                              <td valign="top" class="text"> <span id="kurztipp">
                                Bitte beachten Sie, dass die Anmeldung nur mit vollst&auml;ndigen und korrekten.
                                        </span>
                              <td></td>
                            </tr>
                            <tr>
                              <td height="9"></td>
                              <td></td>
                              <td></td>
                            </tr>
                                  
                                  
                        </table></td>
                        <td rowspan="1" valign="top"><img src="../bilder/standart/1px.gif" width="1" height="1" /></td>
                      </tr>
                            
                      <tr>
                        <td height="253" valign="top"><img src="../bilder/standart/1px.gif" width="1" height="1" /></td>
                        <td></td>
                      </tr>
                            
                      <tr>
                        <td height="10"></td>
                        <td></td>
                      </tr>
                            
                      <tr>
                        <td height="2"></td>
                        <td></td>
                        <td valign="top"><img src="../bilder/standart/1px.gif" width="1" height="1" /></td>
                        <td></td>
                        <td></td>
                      </tr>
                  </table></td>
                      <td></td>
          </tr>
          <tr>
            <td height="25" colspan="3" valign="middle" class="Stil1">User Daten </td>
                  <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td></td>
          </tr>
          <tr>
            <td height="32">&nbsp;</td>
            <td colspan="3" rowspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#F5F5F5">
                      <!--DWLayoutTable-->
                      <tr>
                        <td width="158" height="25" align="right" valign="middle">Username:</td>
                        <td width="6" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
                        <td width="192" valign="middle"><label>
                          <input name="username" type="text" class="spalte2" id="username" maxlength="16" onfocus="ShowQuickTipp(this)" onblur="ShowQuickTipp('default')"/>
                        </label></td>
                      </tr>
                      
                      <tr>
                        <td height="4" colspan="3" valign="top" bgcolor="#FFFFFF"><img src="../bilder/standart/1px.png" width="1" height="1" /></td>
                      </tr>
                      <tr>
                        <td height="25" align="right" valign="middle">Passwort:</td>
                        <td rowspan="2" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
                        <td valign="middle"><label>
                          <input name="passwort" type="password" class="spalte2" id="passwort" maxlength="16"onfocus="ShowQuickTipp(this)" onblur="ShowQuickTipp('default')"/>
                        </label></td>
                      </tr>
                      
                      <tr>
                        <td height="25" align="right" valign="middle">Passwort wiederholen:</td>
                        <td valign="middle"><label>
                          <input name="passwortw" type="password" class="spalte2" id="passwortw" maxlength="16" onfocus="ShowQuickTipp(this)" onblur="ShowQuickTipp('default')"/>
                        </label></td>
                      </tr>
                      <tr>
                        <td height="1"></td>
                        <td></td>
                        <td></td>
                      </tr>
                      <tr>
                        <td height="4" colspan="3" valign="top" bgcolor="#FFFFFF"><img src="../bilder/standart/1px.png" width="1" height="1" /></td>
                      </tr>
                      
                      <tr>
                        <td height="25" align="right" valign="middle">Sicherheitsfrage:</td>
                        <td rowspan="2" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
                        <td valign="middle"><select name="sicherheitsfrage" class="spalte2" id="sicherheitsfrage" onfocus="ShowQuickTipp(this)" onblur="ShowQuickTipp('default')">
                            <option value="">----- Bitte w&auml;hlen -----</option>
                            <option value="1">Wie heißt die Straße in der Sie als Kind gewohnt haben?</option>
                            <option value="2">Wie lautet der Mädchenname Ihrer Mutter?</option>
                            <option value="3">Wie heißt Ihre Großmutter mütterlicherseits?</option>
                            <option value="4">Wie lautet der Familienname Ihrer ersten Freundin bzw. Ihres ersten Freunds?</option>
                            <option value="5">Wo gingen Sie zur Grundschule?</option>
                            <option value="6">Wie heißt Ihr Haustier?</option>
                              </select></td>
                      </tr>
                      
                      <tr>
                        <td height="25" align="right" valign="middle">Geheime Antwort:</td>
                        <td valign="middle"><input name="geheimeantwort" type="text" class="spalte2" id="geheimeantwort"onfocus="ShowQuickTipp(this)" onblur="ShowQuickTipp('default')"/></td>
                      </tr>
                      <tr>
                        <td height="0"></td>
                        <td></td>
                        <td></td>
                      </tr>
                      

              
              
              
                  </table></td>
                  <td rowspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#F5F5F5">
                      <!--DWLayoutTable-->
                      <tr>
                        <td width="25" height="25" align="center" valign="middle"><?php echo $error['usernamebild'];?></td>
                      </tr>
                      <tr>
                        <td height="4" valign="top" bgcolor="#FFFFFF"><img src="../bilder/standart/1px.png" width="1" height="1" /></td>
                      </tr>
                      <tr>
                        <td height="25" align="center" valign="middle"><?php echo $error['passwortbild'];?></td>
                      </tr>
                      <tr>
                        <td height="25" align="center" valign="middle"><?php echo $error['passwortwbild'];?></td>
                      </tr>
                      <tr>
                        <td height="1"></td>
                      </tr>
                      <tr>
                        <td height="4" valign="top" bgcolor="#FFFFFF"><img src="../bilder/standart/1px.png" width="1" height="1" /></td>
                      </tr>
                      
                      <tr>
                        <td height="24" align="center" valign="middle"><?php echo $error['sicherheitsfragebild'];?></td>
                      </tr>
                      
                      <tr>
                        <td height="27" align="center" valign="middle"><?php echo $error['geheimeantwortbild'];?></td>
                      </tr>
                      
                      
                      
                      
                      
                  </table></td>
                  <td>&nbsp;</td>
            <td></td>
          </tr>
          <tr>
            <td height="103">&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td></td>
          </tr>
          <tr>
            <td height="15"></td>
            <td width="156" valign="top"><span class="Stil3">Alle
			Felder sind Pflichtfelder.</span></td>
              <td width="59"></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
          </tr>
          <tr>
            <td height="55"></td>
            <td>&nbsp;</td>
            <td></td>
            <td></td>
            <td></td>
            <td>&nbsp;</td>
            <td></td>
            <td></td>
            <td></td>
          </tr>
          <tr>
            <td height="24"></td>
            <td>&nbsp;</td>
            <td></td>
            <td></td>
            <td></td>
            <td colspan="2" valign="top"> <label>
                <input type="hidden" name="ueberpruefung" value="1" />
                <input type="submit" name="Submit" value="Senden" />
              </label></td>
              <td>&nbsp;</td>
            <td></td>
          </tr>
          
          

            
            

        </table>
        </form>
 
Zuletzt bearbeitet:
Hmm sieht so aus als hättes du das Formular einfach von einer Seite Kopiert und hier reingepostet.
Wenn du was wissen möchtest dann mußt du schon mal ein vernüftige Frage stellen bwz diese erleutern.

Mfg Splasch
 
Oh sorry ganz vergessen:)
Die if Anweisung soll
Fest legen das alle Felder aus gefühlt werden müssen
Die agb akzeptiert werden müssen
Der username und das passwort zwischen 5 und 16 zeichnen besteht
Und bei der geheimeantwort zwischen 3und 30 zeichnen besteht
passwort und passwort-w überein stümt
und das das passwort und geheimeantwort, usernamen nicht mit einander überein stümt

und nein ich hab das Formular selbst geschrieben :):)
 
Im grunde ist der vorgang fast immer gleich wenst prüfen willst ob ein Feld ausgefüllt wurde dann kanste das so machen.

PHP:
<?
if (!isset($_POST['nachname'] || $_POST['nachname']==""){
$fehler.="Das Feld Nachname wurde nicht ausgefüllt";
}
// unsw. das kanste mit jeden Feld machen das du auf eingabe prüfem möchtest.
// bei Mail prüfung wird etwas schwierieger da mußte reguläre ausdrücke verwenden
// etwa so in der art
if($_POST['Email']=="") 
  $fehler.="Bitte das Feld Email ausfüllen.<br>"; 
 else 
  if(!eregi("^([a-z0-9_]|\-|\.)+@(([a-z0-9_]|\-)+\.)+[a-z]{2,4}\$",$_POST['Email'])){ 
    $fehlert.="Bitte geben Sie eine gültige Email-Adresse an.<br>"; }
?>

Mfg Splasch
 
Und wenn du noch Nervige Fenster dazu haben willst nimmst du am besten JavaScript ;)
HTML:
// Pruefen ob der Vorname Eingetragen wurde.
    if(f.Vorname.value=="" || f.Vorname.value==" ") {
    window.alert('Vorname darf nicht leer sein.');
    f.Vorname.select()
    return false; }
 
Oke ich hab da das jetzt zusammen gebastelt:):) aber es funktioniert nicht

PHP:
<?php

    if(isset($_POST['ueberpruefung'])) 
  { 
  
  $allesok = 1; 
  
 
 if(empty($_POST['anrede'])){
  $allesok = 0; 
  $error[anredebild] = "<img src='bilder/hosting/pfeil.gif' width='22' height='22' />";}
 
 if(empty($_POST['vorname'])){
  $allesok = 0; 
  $error[vorname]bild = "<img src='bilder/hosting/pfeil.gif' width='22' height='22' />";}
 
 if(empty($_POST['nachname'])){
  $allesok = 0; 
  $error[nachnamebild] = "<img src='bilder/hosting/pfeil.gif' width='22' height='22' />";}
 
 if(empty($_POST['geburtstag'])){
  $allesok = 0; 
  $error[geburtstagbild] = "<img src='bilder/hosting/pfeil.gif' width='22' height='22' />";}
 
 if(empty($_POST['geburtsmonat'])){
  $allesok = 0; 
  $error[geburtsmonatbild] = "<img src='bilder/hosting/pfeil.gif' width='22' height='22' />";}
 
 if(empty($_POST['geburtsjahr'])){
  $allesok = 0; 
  $error[geburtsjahrbild] = "<img src='bilder/hosting/pfeil.gif' width='22' height='22' />";}
 
 if(empty($_POST['land'])){
  $allesok = 0; 
  $error[landbild] = "<img src='bilder/hosting/pfeil.gif' width='22' height='22' />";}
 
 if(empty($_POST['strasse'])){
  $allesok = 0; 
  $error[strassebild] = "<img src='bilder/hosting/pfeil.gif' width='22' height='22' />";}
 
 if(empty($_POST['plz'])){
  $allesok = 0; 
  $error[plzbild] = "<img src='bilder/hosting/pfeil.gif' width='22' height='22' />";}
 
 if(empty($_POST['ort'])){
  $allesok = 0; 
  $error[ortbild] = "<img src='bilder/hosting/pfeil.gif' width='22' height='22' />";}
 
 if(empty($_POST['email'])){
  $allesok = 0; 
  $error[emailbild] = "<img src='bilder/hosting/pfeil.gif' width='22' height='22' />";}
 
 if(empty($_POST['agb'])){
  $allesok = 0; 
  $error[agbbild] = "<img src='bilder/hosting/pfeil.gif' width='22' height='22' />";}
 
 if(empty($_POST['username'])){
  $allesok = 0; 
  $error[usernamebild] = "<img src='bilder/hosting/pfeil.gif' width='22' height='22' />";}
 
 if(empty($_POST['passwort'])){
  $allesok = 0; 
  $error[passwortbild] = "<img src='bilder/hosting/pfeil.gif' width='22' height='22' />";}
 
 if(empty($_POST['passwortw'])){
  $allesok = 0; 
  $error[passwortwbild] = "<img src='bilder/hosting/pfeil.gif' width='22' height='22' />";}
 
 if(empty($_POST['sicherheitsfrage'])){
  $allesok = 0; 
  $error[sicherheitsfragebild] = "<img src='bilder/hosting/pfeil.gif' width='22' height='22' />";}
 
 if(empty($_POST['geheimeantwort'])){
  $allesok = 0; 
  $error[geheimeantwortbild] = "<img src='bilder/hosting/pfeil.gif' width='22' height='22' />";} 
  
  }
  
  if($allesok){ 
  
 
  echo "Name --- ".$_POST['anrede'];
  echo "<br>";
  echo "Name --- ".$_POST['vorname'];
  echo "<br>";
  echo "Name --- ".$_POST['nachname'];
  echo "<br>";
  echo "Name --- ".$_POST['geburtstag'];
  echo "<br>";
  echo "Name --- ".$_POST['geburtsmonat'];
  echo "<br>";
  echo "Name --- ".$_POST['geburtsjahr'];
  echo "<br>";
  echo "Name --- ".$_POST['land'];
  echo "<br>";
  echo "Name --- ".$_POST['strasse'];
  echo "<br>";
  echo "Name --- ".$_POST['plz'];
  echo "<br>";
  echo "Name --- ".$_POST['ort'];
  echo "<br>";
  echo "Name --- ".$_POST['email'];
  echo "<br>";
  echo "Name --- ".$_POST['agb'];
  echo "<br>";
  echo "Name --- ".$_POST['username'];
  echo "<br>";
  echo "Name --- ".$_POST['passwort'];
  echo "<br>";
  echo "Name --- ".$_POST['passwortw'];
  echo "<br>";
  echo "Name --- ".$_POST['sicherheitsfrage'];
  echo "<br>";
  echo "Name --- ".$_POST['geheimeantwort'];
  echo "<br>";
 
  
  }
  
  else
  {
  ?>
 
Was ist das? Das kann nicht gehen.

PHP:
$error[vorname]bild

Allgemein wird $error[] hier nicht klappen. Du erzeugst hier ein Array. Verwechsel Arrays nicht mit $_POST Variablen. Außerdem müsste man Strings innerhalb der eckigen Klammern mit "" schreiben.

Wenn Du das ganze unbedingt mit einem Ergebnisarray machen willst, was gar keine blöde Idee ist, dann würde das so gehen.

PHP:
$allesok = 0; 
$error = array();
  
 
 if(empty($_POST['anrede'])){
  $allesok++; 
  $error[] = "Anrede nicht ausgefüllt";
}
 if(empty($_POST['vorname'])){
  $allesok++; 
  $error[] = "Vorname nicht ausgefüllt";
}
usw. Für all Deine Felder.

Unten dann eine Prüfung ob es Fehler gegeben hat.
PHP:
#wenn es einen Fehler gegeben hat ist die Zahl größer 0
if($allesok > 0){
     #Fehlerarray auslesen
     foreach($error as $fehlermeldung)
     {
          print $fehlermeldung.'<br />';
     }
}
 
Zuletzt bearbeitet:
Die Variable $allesok ist auch völlig unötig du Prüft einfach ob in der Variable $error ein wert drin steht wenn ja dann gibst eine Fehlermeldung aus.

PHP:
if (isset($error) ){
echo "Fehler aufgetretten<br>".$error;

}else

Mfg Splasch
 

Neue Beiträge

Zurück