whaku Posted December 8, 2012 Share Posted December 8, 2012 Hello, im new here. i see few tutorial here and get stuck in this condition. i make forum, standart forum using php & few javascript. here's my register.php <script type="text/javascript"> function isEmpty(field) { return trim(field.value).length == 0; } function trim(str) { return str.replace(/^\s*([\S\s]*?)\s*$/, '$1'); } function validateAForm() { var form = document.form1; var username = form.username; var pass= form.pass; var email = form.email; var email2 = form.email2; if(isEmpty(username)) { alert("Field UserNama Tidak Boleh Kosong"); username.focus(); return false; //mencegah form disubmit } if(isEmpty(pass)) { alert("Field Password Tidak Boleh Kosong."); pass.focus(); return false; //mencegah form disubmit } if(isEmpty(email)) { alert("Field E-mail Tidak Boleh Kosong"); email.focus(); return false; //mencegah form disubmit } if(email2 != email) { alert("Field Confirm E-mail tidak sama dengan E-mail."); email2.focus(); return false; //mencegah form disubmit } return true; //teruskan submit } </script> <style type="text/css"> <!-- .style1 { color: #FFFFFF; font-weight: bold; } --> </style> <form name="form1" method="post" action="proses_register.php" onsubmit="return validateAForm();"> <table width="83%" border="0" cellpadding="0" cellspacing="2"> <tr> <td colspan="3"><span class="style1"><font color="#0066CC">REGISTER ID</font></span></td> </tr> <tr> <td width="18%"> </td> <td width="1%"> </td> <td width="81%"> </td> </tr> <tr> <td>User Name </td> <td> </td> <td><input name="username" type="text" id="username" size="20" maxlength="20" /> <em>ID anda gunakan saat Login </em></td> </tr> <tr> <td>Password</td> <td> </td> <td><input name="pass" type="password" id="pass" size="15" maxlength="15" /></td> </tr> <tr> <td>E-mail</td> <td> </td> <td><input name="email" type="text" id="email" size="25" /></td> </tr> <tr> <td>Confirm E-mail</td> <td> </td> <td><p> <input name="email2" type="text" id="email2" size="25" /> <br /> </p></td> </tr> <tr> <td>NIM</td> <td> </td> <td><input name="nim" type="text" id="nim" size="10" maxlength="10" /></td> </tr> <tr> <td>Tahun Ajaran</td> <td> </td> <td><label for="tahunajaran"></label> <select name="tahunajaran" id="tahunajaran"> <?php for($a=2000; $a<=2013; $a+=1){ echo"<option value=$a> $a </option>"; } ?> </select></td> </tr> <tr> <td>Tanggal Lahir</td> <td> </td> <td> <select name="tanggal" id="tanggal"> <?php for($b=01; $b<=31; $b+=1){ echo"<option value=$b> $b </option>"; } ?> </select> <label for="bulan"></label> <select name="bulan" id="bulan"> <?php $bulan=array("Januari","Februari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember"); $jlh_bln=count($bulan); for($c=0; $c<$jlh_bln; $c+=1){ echo"<option value=$bulan[$c]> $bulan[$c] </option>"; } ?> </select> <label for="tahun"></label> <select name="tahun" id="tahun"> <?php for($d=2000; $d>=1980; $d-=1){ echo"<option value=$d> $d </option>"; } ?> </select></td> </tr> <tr> <td>Jenis</td> <td> </td> <td> <input type="radio" name="gender" id="gender" value="L" checked="checked" /> Laki-Laki <input type="radio" name="gender" id="gender" value="P" /> Perempun</td> </tr> <tr> <td colspan="3"><p><font size="-1" color="#0066CC">REGISTER CONFIRMATION!<br> </font><font size="-1">Untuk mencegah adanya auto register, mohon masukkan code yang terlihat dibawah!</font></p></td> </tr> <tr> <td colspan="3"><p> <img src="captcha.php" /> <br /> <input name="captcha" type="text" size="10" maxlength="6" /> <br /> </p> <p> </p></td> </tr> <tr> <td> <input type="submit" name="Submit" value="Save" /> <input name="Batal" type="reset" id="Batal" value="Batal" /></td> <td> </td> <td> </td> </tr> </table> </form> 1. I need to make when i put username in that username textfield, automatic search in database its available or not. well its like register on other great forum. 2. i make that captcha, its work but its need progress in proses_register.php, in other words need to open other page to know it granted access to input data or not. i want make it prosess right away after im press submit, maybe like error message in my javascript in 1 row. thanks before, sorry if my code is mess. im still new programer! Quote Link to comment https://forums.phpfreaks.com/topic/271753-auto-check-textfield-available-or-not/ Share on other sites More sharing options...
whaku Posted December 9, 2012 Author Share Posted December 9, 2012 sorry i forgot to include this pict for number 1 question. Quote Link to comment https://forums.phpfreaks.com/topic/271753-auto-check-textfield-available-or-not/#findComment-1398313 Share on other sites More sharing options...
MDCode Posted December 9, 2012 Share Posted December 9, 2012 (edited) 1. Query the database 2. What happens when a user has javascript disabled? Edited December 9, 2012 by SocialCloud Quote Link to comment https://forums.phpfreaks.com/topic/271753-auto-check-textfield-available-or-not/#findComment-1398317 Share on other sites More sharing options...
whaku Posted December 9, 2012 Author Share Posted December 9, 2012 thanks about sugess query. i never think about that, but if im not wrong i do read people say javascript still work (sorry im not pro about this) could u give a way with php then? Quote Link to comment https://forums.phpfreaks.com/topic/271753-auto-check-textfield-available-or-not/#findComment-1398323 Share on other sites More sharing options...
MDCode Posted December 9, 2012 Share Posted December 9, 2012 If a user has javascript disabled, javascript of course will not work. $sql = "SELECT `username` FROM table WHERE `username` = '$username'"; Quote Link to comment https://forums.phpfreaks.com/topic/271753-auto-check-textfield-available-or-not/#findComment-1398324 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.