hallo ma ne frage
ich bin gerade am formular erstellen wo überprüft werden soll ob der user schon in datenbank eingetragen ist.
ich wollte auch das er kontrolliert ob alle felder ausgefüllt wurden
PHP-Code:
<?
include ("../../develop/checkuser.php");
include ("../../develop/config.php");
body();
if($status=="einfuegen"){
$abfrage = "SELECT * FROM mitarbeiter WHERE user='$user' ";
$ergebnis=mysql_query($abfrage);
$row=mysql_fetch_array($ergebnis, MYSQL_ASSOC);
if ($row[user]==$user) {
echo'
<div align="center">
</p>
</p>
<font size="4" face="Verdana, Arial, Helvetica, sans-serif">Username ist schon belegt!</font> </p>
</div>';
exit;
if ($user=="" OR $geschlecht=="" OR $user=="" OR $abteilung=="" OR $nachname=="" OR $vorname=="" OR $e_mail=="" OR $password==""
OR $telefon=="" OR $handy=="" OR $plz=="" OR $ort=="" OR $strasse=="" OR $gebdatum=="" OR $eintritt=="" OR $gehalt=="") {
echo'
<div align="center">
</p>
</p>
<font size="4" face="Verdana, Arial, Helvetica, sans-serif">Es wurden nicht alle Felder ausgefüllt !</font> </p>
</div>';
exit;
}
}else{
$myUpdate=mysql_query("INSERT INTO mitarbeiter
(geschlecht, user, abteilung, nachname, vorname, e_mail, password, telefon, handy, plz, ort, strasse, gebdatum, eintritt, gehalt)
VALUES ('$geschlecht','$user', '$abteilung', '$nachname','$vorname','$e_mail','$password', '$telefon', '$handy','$plz','$ort','$strasse', '$gebdatum', '$eintritt','$gehalt')");
if($myUpdate==1){
echo'
<div align="center">
</p>
</p>
<font size="4" face="Verdana, Arial, Helvetica, sans-serif">Daten wurden erfolgreich eingetragen </font> </p>
</div>';
exit;
}
}
}else
echo "<form name=mb_neu method=\"POST\" action=\"$PHP_SELF\?status=einfuegen\">";
?>
<table width="89%" border="1">
<tr>
<td width="7%"><font color="#000000" size="2"></font></td>
<td width="18%"><font color="#000000" size="2"></font></td>
<td width="6%"><font color="#000000" size="2"></font></td>
<td width="16%"><font color="#000000" size="2">Anrede</font></td>
<td width="6%"><font color="#000000" size="2">Herr
<input name="geschlecht" type="radio" value="Herr" checked>
</font></td>
<td width="16%"><font color="#000000" size="2">Frau
<input type="radio" name="geschlecht" value="Frau">
</font></td>
<td width="8%"><font color="#000000" size="2"></font></td>
<td width="23%"><font color="#99CCFF" size="2"></font></td>
</tr>
<tr>
<td><font color="#000000" size="2">Username</font></td>
<td><font color="#000000" size="2">
<input name="user" type="text" id="user">
</font></td>
<td><font color="#000000" size="2">Abteilung</font></td>
<td><font color="#000000" size="2">
<select name="abteilung" id="abteilung">
<option value="Admin">Admin</option>
<option value="Management">Management</option>
<option value="Einkauf">Einkauf</option>
<option value="Verkauf">Verkauf</option>
<option value="Personal">Personal</option>
<option value="Lager">Lager</option>
<option value="Produktion" selected>Produktion</option>
</select>
</font></td>
<td><font color="#000000" size="2">Nachname</font></td>
<td><font color="#000000" size="2">
<input name="nachname" type="text" id="nachname">
</font></td>
<td><font color="#000000" size="2">Vorname</font></td>
<td><font color="#99CCFF" size="2">
<input name="vorname" type="text" id="vorname">
</font></td>
</tr>
<tr>
<td><font color="#000000" size="2">E Mail</font></td>
<td><font color="#000000" size="2">
<input name="e_mail" type="text" id="e_mail">
</font></td>
<td><font color="#000000" size="2">Passwort</font></td>
<td><font color="#000000" size="2">
<input name="password" type="text" id="password">
</font></td>
<td><font color="#000000" size="2">Telefon</font></td>
<td><font color="#000000" size="2">
<input name="telefon" type="text" id="telefon">
</font></td>
<td><font color="#000000" size="2">Handy</font></td>
<td><font color="#99CCFF" size="2">
<input name="handy" type="text" id="handy">
</font></td>
</tr>
<tr>
<td><font color="#000000" size="2">PLZ</font></td>
<td><font color="#000000" size="2">
<input name="plz" type="text" id="plz">
</font></td>
<td><font color="#000000" size="2">PLZ</font></td>
<td><font color="#000000" size="2">
<input name="ort" type="text" id="ort">
</font></td>
<td><font color="#000000" size="2">Strasse</font></td>
<td><font color="#000000" size="2">
<input name="strasse" type="text" id="strasse">
</font></td>
<td><font color="#000000" size="2">Geburtsdatum</font></td>
<td><font color="#99CCFF" size="2">
<input name="gebdatum" type="text" id="gebdatum">
</font></td>
</tr>
<tr>
<td><font color="#000000" size="2">Eintritt</font></td>
<td><font color="#000000" size="2">
<input name="eintritt" type="text" id="eintritt">
</font></td>
<td><font color="#000000" size="2"></font></td>
<td><font color="#000000" size="2"></font></td>
<td><font color="#000000" size="2">Gehalt</font></td>
<td><font color="#000000" size="2">
<input name="gehalt" type="text" id="gehalt">
</font></td>
<td><font color="#000000" size="2"></font></td>
<td><font color="#99CCFF" size="2"></font></td>
</tr>
<tr>
<td></td>
<td colspan=2 align=center><input type=submit value=Eintragen></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</form>
nur beachtet er dieses if
--> if ($user=="" OR $geschlecht=="" usw.
überhaupt nicht. wie gesagt die überprüfung geht eintragen wird es auch in die datenbank leider auch mnit leeren feldern.
am liebsten wäre mir auch wenn das formular wieder laden wuerde mit dem hinweis der fehler so dass nicht alles wieder neu ausgefüllt werden muss
hat jemand ne idee ?
guten rutsch an die leser