Ich versuche gerade herauszufinden, wie man zum Beispiel beim JoinUs Script eine überprüfung einbauen kann, ob alle Felder ausgefüllt sind, bevor man es Absenden kann.
Da ich zurzeit ein paar kleinere Fehler drin habe. ZB: Wenn einträge fehlen, wird alles zurückgesetzt bis auf Nickname, was etwas störend manchmal ist.
Hier mal mein kompletes Joinus Script ( was durch die Hilfe der Ilch Community soweit sehr super funktioniert)
<?php # Copyright by: Manuel Staechele # Support: www.ilch.de defined ('main') or die ( 'no direct access' ); //-----------------------------------------------------------| $title = $allgAr['title'].' :: Joinus'; $hmenu = 'Joinus'; $design = new design ( $title , $hmenu ); $design->header(); if ( 0 == db_count_query("SELECT COUNT(*) FROM `prefix_groups` WHERE `show_joinus` = 1") ) { echo $lang['noteamthere']; $design->footer(); exit (); } function set_day() { $arDay = array_combine(range(1,31),range(1,31)); return ($arDay); } function set_month() { $arMonth = array_combine(range(1,12),range(1,12)); return ($arMonth); } function set_year() { $firstYear = 1950; $aktYear = date("Y"); $arYear = array_combine(range($firstYear,$aktYear),range($firstYear,$aktYear)); return ($arYear); } $skill_ar = array ( 1 => $lang['verybad'], 2 => $lang['bad'], 3 => $lang['middle'], 4 => $lang['good'], 5 => $lang['verygood'], ); $far = array ( 'name', 'online', 'mail', 'age', 'year', 'month', 'day', 'geschlecht', 'state', 'squad', 'ground', 'tspflicht', // Ab hier beginnen meine eigenen JoinUs-Felder 'wotlink', 'wotnick', 'howmany', 'panzerl', 'freundek', // und hier enden sie. 'rules', ); $x = 0; foreach ($far as $v) { if (!empty($_POST[$v])) { $$v = escape($_POST[$v], 'string'); $x++; } else { $$v = ''; } } $xname = escape_nickname($name); $ch_name = false; if (loggedin()) { $ch_name = true; } elseif (isset($_POST['sub']) AND $name == $xname AND !empty($name) AND 0 == db_result(db_query("SELECT COUNT(*) FROM `prefix_user` WHERE `name` = BINARY '" . $name . "'"),0)) { $ch_name = true; } if (count($far) <> $x OR $ch_name == false) { $tpl = new tpl ( 'joinus.htm' ); $squads = 1; $squaderg = db_query('SELECT `id`, `name` FROM `prefix_groups` WHERE `show_joinus` = 1 ORDER BY pos'); while ($rowsquad = db_fetch_assoc($squaderg)) { if ($squads == 1) { $squad .= '<input type="radio" name="squad" value="' . $rowsquad['id'] . '" checked="checked" />' . $rowsquad['name'] . ' '; } else { $squad .= '<input type="radio" name="squad" value="' . $rowsquad['id'] . '" />' . $rowsquad['name'] . '<br>'; } $squads++; $tpl->set('squad', $squad); } # $squad = '<option value="0">Auswahl!!</option>'; # $squad .= dblistee ($squad, "SELECT id,name FROM prefix_groups WHERE show_joinus = 1 ORDER BY pos"); $geschlecht = escape($_POST['geschlecht'], 'string'); $state = '<option value="0">Land wählen</option>'; $state .= arlistee($state, get_nationality_array()); $year = '<option></option>' . arlistee($year, set_year()); $month = '<option></option>' . arlistee($month, set_month()); $day = '<option></option>' . arlistee($day,set_day()); $tpl->set('year',$year); $tpl->set('month',$month); $tpl->set('day',$day); if (loggedin()) { $name = $_SESSION['authname']; } foreach($far as $v) { if ($x > 0 AND empty($_POST[$v])) { echo 'Es fehlt: ' . $lang[$v] . '<br />'; } $tpl->set ($v, $$v); } if ($x > 0 AND $name != $xname) { echo $lang['wrongnickname'] . '<br />'; } elseif ($x > 0 AND $ch_name == false) { echo $lang['namealreadyinuse'] . '<br />'; } $name = $xname; $tpl->set('readonly', (loggedin()?' readonly': '')); $tpl->out(0); } else { # eintragen $name = $xname; $userreg = $lang['no']; $gebdatum = escape($_POST['year'], 'integer')."-".escape($_POST['month'], 'integer')."-".escape($_POST['day'], 'integer'); if (!loggedin()) { $x = user_regist ($name, $gebdatum, $geschlecht, $state, $mail, genkey(8)); $userreg = $lang['yes']; } db_query("INSERT INTO prefix_usercheck (`check`, name, gebdatum, geschlecht, staat, datime, ak, groupid) VALUES ('" . genkey(8) . "','" . $name . "', gebdatum = '" . $gebdatum . "', '" . $geschlecht . "','" . escape($_POST['state'], 'string') . "', NOW(), 4, $squad)"); $squad = escape($squad, 'integer'); $abf = "SELECT `mod1`, `mod2`, `mod4`, `name` FROM `prefix_groups` WHERE `id` = " . $squad; $erg = db_query($abf); $row = db_fetch_assoc($erg); $tspflichtz = (isset($_POST['tspflicht'])?$_POST['tspflicht']:$lang['no']); $rulz = (isset($_POST['rules'])?$_POST['rules']:$lang['no']); # bitte in der richtigen reihenfolge angeben, sonst das nicht gehen tun, kann. $mailtxt = sprintf ( $lang['joinusprivmsg'], $name, $row['name'], $online, $mail, $age, $gebdatum, $geschlecht, $state, $ground, $tspflichtz, // Hier fangen meine eigenen an. $wotlink, $wotnick, $howmany, $panzerl, $freundek, $rulz, $userreg ); # pm an den leader sendpm ($_SESSION['authid'], $row['mod1'], 'Joinus Anfrage', $mailtxt, -1); # Wenn Co Leader != Leader if ($row['mod2'] != $row['mod1']) { sendpm ($_SESSION['authid'], $row['mod2'], 'Joinus Anfrage', $mailtxt, -1); } if ($row['mod4'] != $row['mod1'] AND $row['mod2'] != $row['mod4']) { sendpm ($_SESSION['authid'], $row['mod4'], 'Joinus Anfrage', $mailtxt, -1); } # pm an alle User aus einer Gruppe senden $userRecht = db_query("SELECT `id`, `recht` FROM `prefix_user`"); while ($row = db_fetch_object($userRecht)) { if ($row->recht == -8) { sendpm($_SESSION['authid'], $row->id, 'Joinus Anfrage', $mailtxt, -1); } } if (!loggedin()) { echo $lang['amailhasbeensenttoyouwithmailandpass'].'<br /><br />'; } echo sprintf($lang['leaderofxalert'], $row['name']); } $design->footer(); ?>
<center><span style="color:red;font-size:10px;"><b>Für das Formular, bitte runter scrollen</b></span></center> <center><img src="include/images/joinus/greenarrowdown.gif" border="0" title=""><img src="include/images/joinus/we_want_you.png" border="0" title=""><img src="include/images/joinus/greenarrowdown.gif" border="0" title=""></center> <form action="index.php?joinus" method="POST"> <fieldset> <legend><b>{_lang_yourdata}:</b></legend> <br /> <br /> <label style="float:left; width:100px; "><i>{_lang_joininfo}:</i></label><i>{_lang_plsfilloutallfields}</i><br /><br /> <label style="float:left; width:100px; ">{_lang_wotnick}:</label><input name="name"{readonly} maxlength="30" value="{name}" /> <br /> <br /> <label style="float:left; width:100px; ">Onlinezeit?</label> <select name="online">{online} <option>Sehr oft</option> <option>Oft</option> <option>Mittelmäßig</option> <option>Selten</option> <option>Am Wochenende</option> <option>Unterschiedlich</option> </select> <br /> <label style="float:left; width:100px; ">E-Mail:</label><input type="text" name="mail" value="{mail}" /> <br /> <label style="float:left; width:100px; ">{_lang_age}:</label><input type="text" name="age" value="{age}" /> <br /> <br /> <label style="float:left; width:100px; ">{_lang_birthday}</label> <select style="margin-bottom:2px; width:75px" name="year" />{year}</select> <select style="margin-bottom:2px; width:75px" name="month" />{month}</select> <select style="margin-bottom:2px; width:50px" name="day" />{day}</select> <font class="smalfont">{_lang_dateformat}</font> <br /> <br /> <label style="float:left; width:100px;">{_lang_sex}</label> <input id="geschlecht1" type="radio" value="1" name="geschlecht" /><label for="geschlecht1"> {_lang_male}</label>, <input id="geschlecht2" type="radio" value="2" name="geschlecht" /><label for="geschlecht2"> {_lang_female}</label>, <input id="geschlecht0" type="radio" value="0" name="geschlecht" /><label for="geschlecht0"> {_lang_itdoesntmatter}</label> <br /> <br /> <label style="float:left; width:100px;">{_lang_state}</label><select name="state">{state}</select> <br /> <br /> <label style="float:left; width:100px; ">Clan:</label>{squad} <br /> <label style="float:left; width:100px; ">Bewerbungstext:</label><textarea name="ground" cols="40" rows="5">{ground}</textarea> <br /> <br /> <label style="float:left; width:100px; ">{_lang_tspflicht}:</label><input type="checkbox" name="tspflicht" value="{_lang_yes}" />{_lang_tspreaded} <br /> <br /> </fieldset> <fieldset> <legend><b>World of Tanks Informationen:</b></legend> <br /> <br /> <label style="float:left; width:100px; ">{_lang_wotlink}:</label> <input type="text" name="wotlink" value="{wotlink}" /> <br /> <br /> <label style="float:left; width:100px; ">{_lang_wotnick}:</label> <input type="text" name="wotnick" value="{wotnick}" /> <br /> <br /> <br /> <label style="float:left; width:100px; ">{_lang_howmany}:</label> <input type="text" name="howmany" value="{howmany}" /> <br /> <br /> <br /> <br /> <label style="float:left; width:100px; ">{_lang_panzerl}:</label> <textarea name="panzerl" cols="40" rows="5">{panzerl}</textarea> <br /> <br /> </fieldset> <fieldset> <legend><b>Zusätzliche Informationen:</b></legend> <br /> <br /> <label style="float:left; width:100px; ">{_lang_freundek}:</label> <textarea name="freundek" cols="40" rows="5">{freundek}</textarea> <br /> <br /> </fieldset> <fieldset> <legend><b>Regeln:</b></legend> <br /> <br /> <label style="float:left; width:100px; ">{_lang_rules}:</label> <input type="checkbox" name="rules" value="{_lang_yes}" />{_lang_rulzreaded} <br /> <br /> <label style="float:left; width:100px; "> </label> <input type="submit" name="sub" value="{_lang_formsub}" /> <br /> </fieldset> </form>
Im Vorraus schonmal vielen Dank
verwendete ilch Version: 1.1 P
betroffene Homepage: caelum-et-infernum.eu