login  Naam:   Wachtwoord: 
Registreer je!
 Forum

[php] formulier.

Offline stenno - 19/10/2005 16:22 (laatste wijziging 20/10/2005 15:07)
Avatar van stennoPHP interesse Beste sitemasters,

Zoals veel van jullie inmiddels wel zullen weten heb ik een registratie formulier gemaakt. Het werkt alleen nog niet helemaal naar wens.

dit is wat ik wil:
http://www.phoe...o=register

Ps. vul maar eens alleen username in en druk gewoon op sign up.
Dan zul je zien dat het formulier niet geleegd wordt. Dus het formulier wordt niet geleegd als er errrors weergegeven worden. Dus wordt de (foute) info ook niet toegevoegd aan de database. En word de info dus pas toegevoegd aan de database als er geen fout ingevulde velden (errors) zijn.

Dit wil ik ook hebben in mijn formulier.
Dus dat de formaction pas word uitgevoerd word wanneer er geen fout ingevulde velden (errors) zijn.

Weet iemand hoe ik dit moet maken. Want wat ik nu heb wordt het formulier geleegd en verzonden. Dus wordt de info ook toegevoegd aan mijn database.

Dit is mijn script nu:
  1. <?php
  2. mysql_connect('host','gebruikersnaam','wachtwoord') or die("couldn't connect to the database. Please try again.");
  3. mysql_select_db('naam_database') or die(mysql_error());
  4. ?>
  5. <html>
  6. <head>
  7. <title></title>
  8. <style type="text/css">
  9. <!--
  10. .error {
  11. background-color:#ffc;
  12. width: 500px;
  13. color: #f00;
  14. font-weight: bold;
  15. padding: 4px;
  16. border: 1px solid #f00;
  17. margin-bottom: 10px;
  18. }
  19. -->
  20. </style>
  21. <script language="JavaScript" type="text/javascript">
  22.  
  23. function check()
  24. {
  25. if ((document.form3.usernamecheck.checked == true)&&(document.form3.nameiscorrect2.checked == true)&&(document.form3.agree.checked == true))
  26. {
  27. document.form3.verzenden.disabled = false;
  28. } else
  29. {
  30. document.form3.verzenden.disabled = true;
  31. }
  32. }
  33. </script>
  34. </head>
  35. <body bgcolor="black" text="white" leftmargin="0px" topmargin="0px" rightmargin="0px" bottommargin="0px">
  36.  
  37. <table bordercolor="darkblue" style="border-collapse:collapse;" cellspacing="0" cellpadding="0" border="1" width="100%">
  38.  
  39. <tr>
  40. <td bgcolor="#696969" align="right" valign="top" width="10%" rowspan="9" background=""></td> <!-- possible advertises go here -->
  41. <td bgcolor="black" width="779" align="center" valign="middle" height="30"></td> <!-- spacer goes here ! -->
  42. <td bgcolor="#696969" align="left" valign="top"width="20%" rowspan="9" background=""></td> <!-- possible advertises go here -->
  43. </tr>
  44. <!-- banner goes here ! -->
  45. <tr>
  46. <td bgcolor="" align="center" valign="middle" height="210"><img src="BANNER5.gif" width="779" height="210"><td>
  47. </tr>
  48. <!-- Top navigation goes here ! -->
  49. <tr>
  50. <td bgcolor="" align="center" valign="middle" height="30">
  51.  
  52. <table border="1" bordercolor="blue" style="border-collapse:collapse;" cellspacing="0" cellpadding="0">
  53. <tr>
  54. <td><A HREF="index.php" onMouseOver="changeimage('aa441','image1on.gif');" onMouseOut="changeimage('aa441','image1.gif');" onClick="changeimage('aa441','image1off.gif');"><IMG src="image1.gif" name=aa441 border="0"></A></td>
  55. <td><A HREF="register.php" onMouseOver="changeimage('aa447','image2on.gif');" onMouseOut="changeimage('aa447','image2.gif');" onClick="changeimage('aa447','image2off.gif');"><IMG src="image2.gif" name=aa447 border="0"></A></td>
  56. <td><A HREF="guide.php" onMouseOver="changeimage('aa386','image3on.gif');" onMouseOut="changeimage('aa386','image3.gif');" onClick="changeimage('aa386','image3off.gif');"><IMG src="image3.gif" name=aa386 border="0"></A></td>
  57. <td><A HREF="calculation.php" onMouseOver="changeimage('aa931','image4on.gif');" onMouseOut="changeimage('aa931','image4.gif');" onClick="changeimage('aa931','image4off.gif');"><IMG src="image4.gif" name=aa931 border="0"></A></td>
  58. <td><A HREF="farmlist.php" onMouseOver="changeimage('aa030','image6on.gif');" onMouseOut="changeimage('aa030','image6.gif');" onClick="changeimage('aa030','image6off.gif');"><IMG src="image6.gif" name=aa030 border="0"></A></td>
  59. <td><A HREF="moc.php" onMouseOver="changeimage('aa958','image7on.gif');" onMouseOut="changeimage('aa958','image7.gif');" onClick="changeimage('aa958','image7off.gif');"><IMG src="image7.gif" name=aa958 border="0"></A></td>
  60. <td><A HREF="faq.php" onMouseOver="changeimage('aa284','image8on.gif');" onMouseOut="changeimage('aa284','image8.gif');" onClick="changeimage('aa284','image8off.gif');"><IMG src="image8.gif" name=aa284 border="0"></A></td>
  61. <td><A HREF="forum.php" onMouseOver="changeimage('aa038','image5on.gif');" onMouseOut="changeimage('aa038','image5.gif');" onClick="changeimage('aa038','image5off.gif');"><IMG src="image5.gif" name=aa038 border="0"></A></td>
  62. </tr>
  63. </table>
  64.  
  65. </td>
  66. </tr>
  67. <!-- titlebar goes here ! -->
  68. <tr>
  69. <td bgcolor="white" height="60" valign="middle"><font face="Matura MT Script Capitals" size="7" color="black">&nbsp;&nbsp;&nbsp;Welcome to the Registerpage</td>
  70. </tr>
  71. <!-- content middle goes here ! -->
  72. <tr>
  73. <td bgcolor="black" align="" valign="top" height="500">
  74. <font size="6" face="">&nbsp;&nbsp;&nbsp;Registrations</font>
  75. <p align="justify>">
  76. <form name="form3" method="post">
  77. <center>
  78. <div style="border-collapse:collapse;border:1px solid;width:750px;">
  79. <center>
  80. <table border="0" bordercolor="" style="border-collapse:collapse;" width="100%">
  81. <tr>
  82. <th height="30" bgcolor="darkblue" align="center" colspan="3"><font size="5">Registrations Profile</font></th>
  83. </tr>
  84.  
  85. <tr>
  86. <td colspan="3" bgcolor="blue"><font color="">&nbsp;&nbsp;&nbsp;Vitals - pay careful attention to what you enter, it's hard to log in if you mess any of it up</font></td>
  87. </tr>
  88.  
  89. <tr>
  90. <td width="20%" valign="bottom">Username:</td>
  91. <td><font size="2"> This is required to be exactly the same as your Kings of Chaos username; the system will not work with any other name. Watch out for capitalization. (To be sure you get the right name, simply go to Command Center in Kings of Chaos, highlight your name at the top right corner of the User Info table, and paste it here.)<font></td>
  92. </tr>
  93.  
  94. <tr>
  95. <td valign="top"><input type="textinput" name="username" size="25" value=""/></td>
  96. <td><span id="spanuser" class="error" style="display:none">No valid Username!</span><span id="spanused" class="error" style="display:none">There is already someone with that username!</span><input type="checkbox" name="usernamecheck" onclick="javascript:check();"/>OK, I checked my username at Kings of Chaos and put it in the box correctly. <b>(MUST be checked)</b></td>
  97. </tr>
  98.  
  99. <tr>
  100. <td width="20%" valign="bottom">Password:</td>
  101. </tr>
  102.  
  103. <tr>
  104. <td valign="top"><input type="password" name="password1" size="25" value=""/></td>
  105. </tr>
  106.  
  107. <tr>
  108. <td width="20%" valign="bottom"></td>
  109. <td><span id="spannopassword" class="error" style="display:none">You may not sign up with a blank Password!</span><span id="spanpassword" class="error" style="display:none">Passwords do not match!</span>
  110. </tr>
  111.  
  112. <tr>
  113. <td width="20%" valign="bottom">Password again:</td>
  114. </tr>
  115.  
  116. <tr>
  117. <td valign="top"><input type="password" name="password2" size="25" value=""/></td>
  118. </tr>
  119.  
  120. <tr>
  121. <td width="20%" valign="bottom">Email address:</td>
  122. </tr>
  123.  
  124. <tr>
  125. <td valign="top"><input type="textinput" name="email" size="25" value=""/>&nbsp;&nbsp;</td>
  126. <td><span id="spanemail" class="error" style="display:none">No valid Emailaddress!</span><font color="red"> If you use a free webmail service such as Yahoo! or Hotmail, it is highly likely that your password will disappear into their spam filters. Please make sure that you NOTE DOWN YOUR PASSWORD when it appears on this site in a moment.</font></td>
  127. </tr>
  128.  
  129. <tr>
  130. <td width="20%" valign="bottom">Kings of Chaos Link:</td>
  131. <td valign="bottom"><span id="spanlink" class="error" style="display:none">No valid Uniquelink!</span></td>
  132. </tr>
  133.  
  134. <tr>
  135. <td colspan="2"><input type="textinput" name="userlink" size="40" value=""/>
  136. </td>
  137. </tr>
  138.  
  139. <tr>
  140. <td colspan="2" height="40"></td>
  141. </tr>
  142.  
  143. <tr>
  144. <td colspan="2" height="30"></td>
  145. </tr>
  146.  
  147. <tr>
  148. <td width="20%" valign="bottom">Current Army Size:</td>
  149. </tr>
  150.  
  151. <tr>
  152. <td width="20%" colspan="" valign="top"><input type="textinput" name="armysize" size="5" />
  153. <select name="race">
  154. <option value="Humans">Humans</option>
  155. <option value="Dwarves">Dwarves</option>
  156. <option value="Elves">Elves</option>
  157. <option value="Orcs">Orcs</option>
  158. </select>
  159. </td>
  160. <td colspan="2">
  161. <span id="spanarmy" class="error" style="display:none">No valid Armysize!</span>
  162. </td>
  163. </tr>
  164.  
  165. <tr>
  166. <td colspan="2" height="10"></td>
  167. </tr>
  168.  
  169. <tr bgcolor="darkblue">
  170. <td colspan="2" height="30"><font size="5"><b>Alliance</b></font></td>
  171. </tr>
  172.  
  173. <tr>
  174. <td valign="middle">
  175. <select name="alliance">
  176. <option value="0" selected="selected" >Select an alliance from the list</option>
  177. <option value="Lords of Gondor Member" >LOG Member</option>
  178. <option value="Lordclicker User" >Lordclicker User</option>
  179. </select>
  180. </td>
  181. <td>Please select 'Lordclicker User', unless you are a member of Lords of Gondor.<br />&nbsp;<span id="spanalliance" class="error" style="display:none">Please select an Alliance!</span><input type="checkbox" onclick="javascript:check();" name="nameiscorrect2"/>I have selected an appropriate alliance <b>(MUST be checked)</b></td>
  182. </tr>
  183.  
  184. <tr bgcolor="darkblue">
  185. <td colspan="2" height="30"><font size="5"><b>Agreement</b></font></td>
  186. </tr>
  187.  
  188. <tr>
  189. <td colspan="2">
  190. You need to have checked all three check boxes in this form.<br /><br />
  191. Checking this one signifies one of the following two: <ol><li>that you are a member of Lords of Gondor or are in its command chain, and as such, you will not attack or attempt to recruit as an officer ANYONE in Lords of Gondor or its command chain, and that you will uphold the high standards of gameplay and citizenship that have come to be the trademarks of Lords of Gondor; that you will not break Kings of Chaos rules, spam or harass people in the game or out; that you understand you must most definitely kick ass in the game. (That's what we're all about)<br /><br /><b>or</b><br/><br/></li><li>that you agree that you are NOT in an alliance which is an enemy of Lords of Gondor</li></ol>
  192. <input type="checkbox" name="agree" onclick="javascript:check();"/> I agree to one of the two above statements. <b>(MUST be checked)</b>
  193. </td>
  194. </tr>
  195.  
  196. <tr>
  197. <td colspan="2" height="10"></td>
  198. </tr>
  199.  
  200. <tr>
  201. <td colspan="2" align="center"><input type="submit" name="verzenden" value="Sign up" disabled/></td>
  202. </tr>
  203.  
  204. <tr>
  205. <td colspan="2" height="10"></td>
  206. </tr>
  207.  
  208. </table>
  209. </center>
  210. </div>
  211. </center>
  212. </form>
  213. </p>
  214. </td>
  215. </tr>
  216. <!-- spacer goes here ! -->
  217. <tr>
  218. <td bgcolor='white' align="center" valign="middle" height="2"></td>
  219. </tr>
  220. <!-- bottom navigation goes here ! -->
  221. <tr>
  222. <td bgcolor="black" align="center" valign="middle"height="40">
  223. <A class="type1" href="mailto:LOG_admins@hotmail.com">Contact us</A> | <a class="type1" href="termsofservice.htm" target="_self">Terms of Service</a> | <a class="type1" href="advertising.htm" target="_self">Advertising</a><br />
  224. </td>
  225. </tr>
  226. <!-- spacer goes here ! -->
  227. <tr>
  228. <td bgcolor='white' align="center" valign="middle" height="2"></td>
  229. </tr>
  230. <!-- footer goes here ! -->
  231. <tr>
  232. <td bgcolor="black" align="center" valign="middle"height="50">
  233. <font size="2">Created by&nbsp;
  234. <a class="type1" href="http://www.kingsofchaos.com/recruit.php?uniqid=8tx26d8t" target="_blank">Stenno </a> and <a class="type1" href="http://www.kingsofchaos.com/recruit.php?uniqid=46k39bpy" target="_blank">Warhol</a> <br />
  235. <I>Copyright © 2004-2005 Lords of Gondor, All rights reserved.</I></br>
  236. </font>
  237. </td>
  238. </tr>
  239.  
  240. </table>
  241. <?php
  242.  
  243. if(isset($_POST['verzenden'])) {
  244. // Formulier verzonden
  245. if(trim($_POST['username']) == "") {
  246. // veld leeg?
  247. ?>
  248. <script language="javascript" type="text/javascript">
  249. document.getElementById('spanuser').style.display = 'block';
  250. </script>
  251. <?php
  252. } else {
  253. ?>
  254. <script language="javascript" type="text/javascript">
  255. document.getElementById('spanuser').style.display = 'none';
  256. </script>
  257. <?php
  258. // Het veld is niet leeg, controleren of de gebruikersnaam nog niet bestaat
  259. $controle = mysql_result(mysql_query("SELECT COUNT(id) FROM users WHERE username= '".$_POST['username']."'"),0);
  260. if($controle != 0) {
  261. ?>
  262. <script language="javascript" type="text/javascript">
  263. document.getElementById('spanused').style.display = 'block';
  264. </script>
  265. <?php
  266. } else {
  267. ?>
  268. <script language="javascript" type="text/javascript">
  269. document.getElementById('spanused').style.display = 'none';
  270. </script>
  271. <?php
  272. }
  273. }
  274. if(trim($_POST['email']) == "") {
  275. ?>
  276. <script language="javascript" type="text/javascript">
  277. document.getElementById('spanemail').style.display = 'block';
  278. </script>
  279. <?php
  280. } else {
  281. ?>
  282. <script language="javascript" type="text/javascript">
  283. document.getElementById('spanemail').style.display = 'none';
  284. </script>
  285. <?php
  286. }
  287. if(trim($_POST['userlink']) == "") {
  288. ?>
  289. <script language="javascript" type="text/javascript">
  290. document.getElementById('spanlink').style.display = 'block';
  291. </script>
  292. <?php
  293. } else {
  294. ?>
  295. <script language="javascript" type="text/javascript">
  296. document.getElementById('spanlink').style.display = 'none';
  297. </script>
  298. <?php
  299. }
  300. if(trim($_POST['armysize']) == "" || !is_numeric($_POST['armysize'])) {
  301. ?>
  302. <script language="javascript" type="text/javascript">
  303. document.getElementById('spanarmy').style.display = 'block';
  304. </script>
  305. <?php
  306. } elseif(trim($_POST['armysize']) != "" && is_numeric($_POST['armysize'])) {
  307. ?>
  308. <script language="javascript" type="text/javascript">
  309. document.getElementById('spanarmy').style.display = 'none';
  310. </script>
  311. <?php
  312. }
  313. if($_POST['alliance'] == "0") {
  314. ?>
  315. <script language="javascript" type="text/javascript">
  316. document.getElementById('spanalliance').style.display = 'block';
  317. </script>
  318. <?php
  319. } else {
  320. ?>
  321. <script language="javascript" type="text/javascript">
  322. document.getElementById('spanalliance').style.display = 'none';
  323. </script>
  324. <?php
  325. }
  326. if($_POST['password1'] == "" && $_POST['password2'] == "") {
  327. ?>
  328. <script language="javascript" type="text/javascript">
  329. document.getElementById('spannopassword').style.display = 'block';
  330. </script>
  331. <?php
  332. } else {
  333. ?>
  334. <script language="javascript" type="text/javascript">
  335. document.getElementById('spannopassword').style.display = 'none';
  336. </script>
  337. <?php
  338. if($_POST['password1'] != $_POST['password2']) {
  339. ?>
  340. <script language="javascript" type="text/javascript">
  341. document.getElementById('spanpassword').style.display = 'block';
  342. </script>
  343. <?php
  344. } else {
  345. ?>
  346. <script language="javascript" type="text/javascript">
  347. document.getElementById('spanpassword').style.display = 'none';
  348. </script>
  349. <?php
  350. }
  351. }
  352.  
  353.  
  354.  
  355. }
  356.  
  357. ?>
  358. </body>
  359. </html>


ps dit is de code om een error weertegeven:

  1. <script language="javascript" type="text/javascript">
  2. document.getElementById('ID').style.display = 'block'; // vul ipv ID het id van de span in.
  3. </script>


en dit om hem weer te verberen:

  1. <script language="javascript" type="text/javascript">
  2. document.getElementById('ID').style.display = 'none'; // vul ipv ID het id van de span in.
  3. </script>


Mag ik misschien geen submit-button gebruiken ?? maar dan kan ik dus ook de variable $_POST[''] niet gebruiken:\

Ik denk dat hier javascript aan te pas moet komen:!:

met onsubmit() ofzo.

8 antwoorden

Gesponsorde links
Offline Rens - 19/10/2005 16:29
Avatar van Rens Gouden medaille

Crew algemeen
Gewoon tellen of er al een rij bestaat met die username/email adres.
  1. "SELECT COUNT(id) FROM leden WHERE username='".$username."';
  2. if(MySQL_Result($rResult, 0) == 1)
  3. {
  4. // bestaat
  5. } else
  6. {
  7. // bestaat niet
  8. // hier hetzelfde, maar dan voor email adres
  9. }

http://www.site...id=258#2_1
Offline TFOL - 19/10/2005 16:33 (laatste wijziging 19/10/2005 16:37)
Avatar van TFOL PHP beginner Dit gebruik ik vaak:

  1. <?php
  2.  
  3. $q1 = "SELECT * FROM users WHERE username = '".$_POST['username']."' OR email = '".$_POST['email']."'";
  4. $sql = mysql_query($q1) or die(mysql_error());
  5. $i = mysql_num_rows($sql);
  6.  
  7. if($i != 0)
  8. {
  9. //email en/of username is al in gebruik
  10.  
  11. }
  12. else
  13. {
  14. //email en username zijn nog niet in gebruikt
  15.  
  16. }
  17. ?>


edit: ik type weer is te sloom 

edit 2: Bij javascript kom ik niet verder dan document.write('tekst'); wordt tijd dat ik het leer;-)
Offline stenno - 19/10/2005 16:34 (laatste wijziging 19/10/2005 16:40)
Avatar van stenno PHP interesse Ja je hebt gelijk lijkt me inderdaad een iets makkelijkere manier om te controleren of de username al bestaat.

Maar ik zit nog steeds met het probleem: hoe krijg ik het in mijn javascript.

edit ik wil trouwens graag de emailcontrole en de username controle in een apparte functie maar dat is maar een detail als ik weet hoe ik het bij de ene moet doen kan ik het ook bij de andere.:p

edit2) zou ik misschien in het If en Else gedeelte een variable false of true mee kunnen geven. en die in het if en else statement van mijn javascript kunnen checken ??
Offline Rens - 19/10/2005 16:43
Avatar van Rens Gouden medaille

Crew algemeen
Misschien iets van if(<?=$var;?> != document.bla) ?
Offline stenno - 19/10/2005 18:59 (laatste wijziging 19/10/2005 22:33)
Avatar van stenno PHP interesse okeej inmiddels mijn hele code omgeschreven naar php op advies van murfy

hier is hij dan:

  1. <?php
  2. mysql_connect('host','gebruikersnaam','wachtwoord') or die("couldn't connect to the database. Please try again.");
  3. mysql_select_db('naam_database') or die(mysql_error());
  4. ?>
  5. <html>
  6. <head>
  7. <title></title>
  8. <style type="text/css">
  9. <!--
  10. .error {
  11. background-color:#ffc;
  12. width: 500px;
  13. color: #f00;
  14. font-weight: bold;
  15. padding: 4px;
  16. border: 1px solid #f00;
  17. margin-bottom: 10px;
  18. }
  19. -->
  20. </style>
  21. <script language="JavaScript" type="text/javascript">
  22.  
  23. function check()
  24. {
  25. if ((document.form3.usernamecheck.checked == true)&&(document.form3.nameiscorrect2.checked == true)&&(document.form3.agree.checked == true))
  26. {
  27. document.form3.verzenden.disabled = false;
  28. } else
  29. {
  30. document.form3.verzenden.disabled = true;
  31. }
  32. }
  33. </script>
  34. </head>
  35. <body bgcolor="black" text="white" leftmargin="0px" topmargin="0px" rightmargin="0px" bottommargin="0px">
  36.  
  37. <table bordercolor="darkblue" style="border-collapse:collapse;" cellspacing="0" cellpadding="0" border="1" width="100%">
  38.  
  39. <tr>
  40. <td bgcolor="#696969" align="right" valign="top" width="10%" rowspan="9" background=""></td> <!-- possible advertises go here -->
  41. <td bgcolor="black" width="779" align="center" valign="middle" height="30"></td> <!-- spacer goes here ! -->
  42. <td bgcolor="#696969" align="left" valign="top"width="20%" rowspan="9" background=""></td> <!-- possible advertises go here -->
  43. </tr>
  44. <!-- banner goes here ! -->
  45. <tr>
  46. <td bgcolor="" align="center" valign="middle" height="210"><img src="BANNER5.gif" width="779" height="210"><td>
  47. </tr>
  48. <!-- Top navigation goes here ! -->
  49. <tr>
  50. <td bgcolor="" align="center" valign="middle" height="30">
  51.  
  52. <table border="1" bordercolor="blue" style="border-collapse:collapse;" cellspacing="0" cellpadding="0">
  53. <tr>
  54. <td><A HREF="index.php" onMouseOver="changeimage('aa441','image1on.gif');" onMouseOut="changeimage('aa441','image1.gif');" onClick="changeimage('aa441','image1off.gif');"><IMG src="image1.gif" name=aa441 border="0"></A></td>
  55. <td><A HREF="register.php" onMouseOver="changeimage('aa447','image2on.gif');" onMouseOut="changeimage('aa447','image2.gif');" onClick="changeimage('aa447','image2off.gif');"><IMG src="image2.gif" name=aa447 border="0"></A></td>
  56. <td><A HREF="guide.php" onMouseOver="changeimage('aa386','image3on.gif');" onMouseOut="changeimage('aa386','image3.gif');" onClick="changeimage('aa386','image3off.gif');"><IMG src="image3.gif" name=aa386 border="0"></A></td>
  57. <td><A HREF="calculation.php" onMouseOver="changeimage('aa931','image4on.gif');" onMouseOut="changeimage('aa931','image4.gif');" onClick="changeimage('aa931','image4off.gif');"><IMG src="image4.gif" name=aa931 border="0"></A></td>
  58. <td><A HREF="farmlist.php" onMouseOver="changeimage('aa030','image6on.gif');" onMouseOut="changeimage('aa030','image6.gif');" onClick="changeimage('aa030','image6off.gif');"><IMG src="image6.gif" name=aa030 border="0"></A></td>
  59. <td><A HREF="moc.php" onMouseOver="changeimage('aa958','image7on.gif');" onMouseOut="changeimage('aa958','image7.gif');" onClick="changeimage('aa958','image7off.gif');"><IMG src="image7.gif" name=aa958 border="0"></A></td>
  60. <td><A HREF="faq.php" onMouseOver="changeimage('aa284','image8on.gif');" onMouseOut="changeimage('aa284','image8.gif');" onClick="changeimage('aa284','image8off.gif');"><IMG src="image8.gif" name=aa284 border="0"></A></td>
  61. <td><A HREF="forum.php" onMouseOver="changeimage('aa038','image5on.gif');" onMouseOut="changeimage('aa038','image5.gif');" onClick="changeimage('aa038','image5off.gif');"><IMG src="image5.gif" name=aa038 border="0"></A></td>
  62. </tr>
  63. </table>
  64.  
  65. </td>
  66. </tr>
  67. <!-- titlebar goes here ! -->
  68. <tr>
  69. <td bgcolor="white" height="60" valign="middle"><font face="Matura MT Script Capitals" size="7" color="black">&nbsp;&nbsp;&nbsp;Welcome to the Registerpage</td>
  70. </tr>
  71. <!-- content middle goes here ! -->
  72. <tr>
  73. <td bgcolor="black" align="" valign="top" height="500">
  74. <font size="6" face="">&nbsp;&nbsp;&nbsp;Registrations</font>
  75. <p align="justify>">
  76. <form name="form3" method="post">
  77. <center>
  78. <div style="border-collapse:collapse;border:1px solid;width:750px;">
  79. <center>
  80. <table border="0" bordercolor="" style="border-collapse:collapse;" width="100%">
  81. <tr>
  82. <th height="30" bgcolor="darkblue" align="center" colspan="3"><font size="5">Registrations Profile</font></th>
  83. </tr>
  84.  
  85. <tr>
  86. <td colspan="3" bgcolor="blue"><font color="">&nbsp;&nbsp;&nbsp;Vitals - pay careful attention to what you enter, it's hard to log in if you mess any of it up</font></td>
  87. </tr>
  88.  
  89. <tr>
  90. <td width="20%" valign="bottom">Username:</td>
  91. <td><font size="2"> This is required to be exactly the same as your Kings of Chaos username; the system will not work with any other name. Watch out for capitalization. (To be sure you get the right name, simply go to Command Center in Kings of Chaos, highlight your name at the top right corner of the User Info table, and paste it here.)<font></td>
  92. </tr>
  93.  
  94. <tr>
  95. <td valign="top"><input type="textinput" name="username" size="25" value=""/></td>
  96. <td><span id="spanuser" class="error" style="display:none">No valid Username!</span><span id="spanused" class="error" style="display:none">There is already someone with that username!</span><input type="checkbox" name="usernamecheck" onclick="javascript:check();"/>OK, I checked my username at Kings of Chaos and put it in the box correctly. <b>(MUST be checked)</b></td>
  97. </tr>
  98.  
  99. <tr>
  100. <td width="20%" valign="bottom">Password:</td>
  101. </tr>
  102.  
  103. <tr>
  104. <td valign="top"><input type="password" name="password1" size="25" value=""/></td>
  105. </tr>
  106.  
  107. <tr>
  108. <td width="20%" valign="bottom"></td>
  109. <td><span id="spannopassword" class="error" style="display:none">You may not sign up with a blank Password!</span><span id="spanpassword" class="error" style="display:none">Passwords do not match!</span>
  110. </tr>
  111.  
  112. <tr>
  113. <td width="20%" valign="bottom">Password again:</td>
  114. </tr>
  115.  
  116. <tr>
  117. <td valign="top"><input type="password" name="password2" size="25" value=""/></td>
  118. </tr>
  119.  
  120. <tr>
  121. <td width="20%" valign="bottom">Email address:</td>
  122. </tr>
  123.  
  124. <tr>
  125. <td valign="top"><input type="textinput" name="email" size="25" value=""/>&nbsp;&nbsp;</td>
  126. <td><span id="spanemail" class="error" style="display:none">No valid Emailaddress!</span><font color="red"> If you use a free webmail service such as Yahoo! or Hotmail, it is highly likely that your password will disappear into their spam filters. Please make sure that you NOTE DOWN YOUR PASSWORD when it appears on this site in a moment.</font></td>
  127. </tr>
  128.  
  129. <tr>
  130. <td width="20%" valign="bottom">Kings of Chaos Link:</td>
  131. <td valign="bottom"><span id="spanlink" class="error" style="display:none">No valid Uniquelink!</span></td>
  132. </tr>
  133.  
  134. <tr>
  135. <td colspan="2"><input type="textinput" name="userlink" size="40" value=""/>
  136. </td>
  137. </tr>
  138.  
  139. <tr>
  140. <td colspan="2" height="40"></td>
  141. </tr>
  142.  
  143. <tr>
  144. <td colspan="2" height="30"></td>
  145. </tr>
  146.  
  147. <tr>
  148. <td width="20%" valign="bottom">Current Army Size:</td>
  149. </tr>
  150.  
  151. <tr>
  152. <td width="20%" colspan="" valign="top"><input type="textinput" name="armysize" size="5" />
  153. <select name="race">
  154. <option value="Humans">Humans</option>
  155. <option value="Dwarves">Dwarves</option>
  156. <option value="Elves">Elves</option>
  157. <option value="Orcs">Orcs</option>
  158. </select>
  159. </td>
  160. <td colspan="2">
  161. <span id="spanarmy" class="error" style="display:none">No valid Armysize!</span>
  162. </td>
  163. </tr>
  164.  
  165. <tr>
  166. <td colspan="2" height="10"></td>
  167. </tr>
  168.  
  169. <tr bgcolor="darkblue">
  170. <td colspan="2" height="30"><font size="5"><b>Alliance</b></font></td>
  171. </tr>
  172.  
  173. <tr>
  174. <td valign="middle">
  175. <select name="alliance">
  176. <option value="0" selected="selected" >Select an alliance from the list</option>
  177. <option value="Lords of Gondor Member" >LOG Member</option>
  178. <option value="Lordclicker User" >Lordclicker User</option>
  179. </select>
  180. </td>
  181. <td>Please select 'Lordclicker User', unless you are a member of Lords of Gondor.<br />&nbsp;<span id="spanalliance" class="error" style="display:none">Please select an Alliance!</span><input type="checkbox" onclick="javascript:check();" name="nameiscorrect2"/>I have selected an appropriate alliance <b>(MUST be checked)</b></td>
  182. </tr>
  183.  
  184. <tr bgcolor="darkblue">
  185. <td colspan="2" height="30"><font size="5"><b>Agreement</b></font></td>
  186. </tr>
  187.  
  188. <tr>
  189. <td colspan="2">
  190. You need to have checked all three check boxes in this form.<br /><br />
  191. Checking this one signifies one of the following two: <ol><li>that you are a member of Lords of Gondor or are in its command chain, and as such, you will not attack or attempt to recruit as an officer ANYONE in Lords of Gondor or its command chain, and that you will uphold the high standards of gameplay and citizenship that have come to be the trademarks of Lords of Gondor; that you will not break Kings of Chaos rules, spam or harass people in the game or out; that you understand you must most definitely kick ass in the game. (That's what we're all about)<br /><br /><b>or</b><br/><br/></li><li>that you agree that you are NOT in an alliance which is an enemy of Lords of Gondor</li></ol>
  192. <input type="checkbox" name="agree" onclick="javascript:check();"/> I agree to one of the two above statements. <b>(MUST be checked)</b>
  193. </td>
  194. </tr>
  195.  
  196. <tr>
  197. <td colspan="2" height="10"></td>
  198. </tr>
  199.  
  200. <tr>
  201. <td colspan="2" align="center"><input type="submit" name="verzenden" value="Sign up" disabled/></td>
  202. </tr>
  203.  
  204. <tr>
  205. <td colspan="2" height="10"></td>
  206. </tr>
  207.  
  208. </table>
  209. </center>
  210. </div>
  211. </center>
  212. </form>
  213. </p>
  214. </td>
  215. </tr>
  216. <!-- spacer goes here ! -->
  217. <tr>
  218. <td bgcolor='white' align="center" valign="middle" height="2"></td>
  219. </tr>
  220. <!-- bottom navigation goes here ! -->
  221. <tr>
  222. <td bgcolor="black" align="center" valign="middle"height="40">
  223. <A class="type1" href="mailto:LOG_admins@hotmail.com">Contact us</A> | <a class="type1" href="termsofservice.htm" target="_self">Terms of Service</a> | <a class="type1" href="advertising.htm" target="_self">Advertising</a><br />
  224. </td>
  225. </tr>
  226. <!-- spacer goes here ! -->
  227. <tr>
  228. <td bgcolor='white' align="center" valign="middle" height="2"></td>
  229. </tr>
  230. <!-- footer goes here ! -->
  231. <tr>
  232. <td bgcolor="black" align="center" valign="middle"height="50">
  233. <font size="2">Created by&nbsp;
  234. <a class="type1" href="http://www.kingsofchaos.com/recruit.php?uniqid=8tx26d8t" target="_blank">Stenno </a> and <a class="type1" href="http://www.kingsofchaos.com/recruit.php?uniqid=46k39bpy" target="_blank">Warhol</a> <br />
  235. <I>Copyright © 2004-2005 Lords of Gondor, All rights reserved.</I></br>
  236. </font>
  237. </td>
  238. </tr>
  239.  
  240. </table>
  241. <?php
  242.  
  243. if(isset($_POST['verzenden'])) {
  244. // Formulier verzonden
  245. if(trim($_POST['username']) == "") {
  246. // veld leeg?
  247. ?>
  248. <script language="javascript" type="text/javascript">
  249. document.getElementById('spanuser').style.display = 'block';
  250. </script>
  251. <?php
  252. } else {
  253. ?>
  254. <script language="javascript" type="text/javascript">
  255. document.getElementById('spanuser').style.display = 'none';
  256. </script>
  257. <?php
  258. // Het veld is niet leeg, controleren of de gebruikersnaam nog niet bestaat
  259. $controle = mysql_result(mysql_query("SELECT COUNT(id) FROM users WHERE username= '".$_POST['username']."'"),0);
  260. if($controle != 0) {
  261. ?>
  262. <script language="javascript" type="text/javascript">
  263. document.getElementById('spanused').style.display = 'block';
  264. </script>
  265. <?php
  266. } else {
  267. ?>
  268. <script language="javascript" type="text/javascript">
  269. document.getElementById('spanused').style.display = 'none';
  270. </script>
  271. <?php
  272. }
  273. }
  274. if(trim($_POST['email']) == "") {
  275. ?>
  276. <script language="javascript" type="text/javascript">
  277. document.getElementById('spanemail').style.display = 'block';
  278. </script>
  279. <?php
  280. } else {
  281. ?>
  282. <script language="javascript" type="text/javascript">
  283. document.getElementById('spanemail').style.display = 'none';
  284. </script>
  285. <?php
  286. }
  287. if(trim($_POST['userlink']) == "") {
  288. ?>
  289. <script language="javascript" type="text/javascript">
  290. document.getElementById('spanlink').style.display = 'block';
  291. </script>
  292. <?php
  293. } else {
  294. ?>
  295. <script language="javascript" type="text/javascript">
  296. document.getElementById('spanlink').style.display = 'none';
  297. </script>
  298. <?php
  299. }
  300. if(trim($_POST['armysize']) == "" || !is_numeric($_POST['armysize'])) {
  301. ?>
  302. <script language="javascript" type="text/javascript">
  303. document.getElementById('spanarmy').style.display = 'block';
  304. </script>
  305. <?php
  306. } elseif(trim($_POST['armysize']) != "" && is_numeric($_POST['armysize'])) {
  307. ?>
  308. <script language="javascript" type="text/javascript">
  309. document.getElementById('spanarmy').style.display = 'none';
  310. </script>
  311. <?php
  312. }
  313. if($_POST['alliance'] == "0") {
  314. ?>
  315. <script language="javascript" type="text/javascript">
  316. document.getElementById('spanalliance').style.display = 'block';
  317. </script>
  318. <?php
  319. } else {
  320. ?>
  321. <script language="javascript" type="text/javascript">
  322. document.getElementById('spanalliance').style.display = 'none';
  323. </script>
  324. <?php
  325. }
  326. if($_POST['password1'] == "" && $_POST['password2'] == "") {
  327. ?>
  328. <script language="javascript" type="text/javascript">
  329. document.getElementById('spannopassword').style.display = 'block';
  330. </script>
  331. <?php
  332. } else {
  333. ?>
  334. <script language="javascript" type="text/javascript">
  335. document.getElementById('spannopassword').style.display = 'none';
  336. </script>
  337. <?php
  338. if($_POST['password1'] != $_POST['password2']) {
  339. ?>
  340. <script language="javascript" type="text/javascript">
  341. document.getElementById('spanpassword').style.display = 'block';
  342. </script>
  343. <?php
  344. } else {
  345. ?>
  346. <script language="javascript" type="text/javascript">
  347. document.getElementById('spanpassword').style.display = 'none';
  348. </script>
  349. <?php
  350. }
  351. }
  352.  
  353.  
  354.  
  355. }
  356.  
  357. ?>
  358. </body>
  359. </html>


Het probleem is dat als er iets niet (goed) is ingevuld en je drukt op sign up. Hij de info zal opslaan in mijn database wanneer ik een action="" toevoeg aan mijn form tag. En hij op dit moment wel de errors juist weergeeft alleen hij na drukken op de sign up button natuurlijk de ingevulde velden leeg maakt! en dat is nou net wat ik niet wil !! Ik wil dat er geen fout info in mijn mysql database wordt opgeslagen en dat de errors goed weergegeven worden naast mijn (fout) ingevulde velden.

Weet iemand hoe ik dit wel juist doe ??
Offline Ibrahim - 20/10/2005 08:59 (laatste wijziging 20/10/2005 09:06)
Avatar van Ibrahim PHP expert in elke veld de value zetten $_POST['veldnaam']

Error berichten in een variable zetten en naast het veld de bijbehorende error weergeven.
Offline stenno - 20/10/2005 09:13 (laatste wijziging 20/10/2005 09:29)
Avatar van stenno PHP interesse Dat dat met die values vind ik een goed idee.

Bedankt, maar hoe doe ik dat precies kan dat uberhaupt wel met php ??

En ik zit nog steeds met het probleem dat er foute informatie in mijn mysql database zal komen.;-) 
Offline nielsvdwal - 20/10/2005 12:30 (laatste wijziging 20/10/2005 12:31)
Avatar van nielsvdwal PHP gevorderde
  1. <?php
  2. if ($_POST['username'] == $database['username'])
  3. {
  4. // bestaat al
  5. }
  6. else
  7. {
  8. // in de database zetten..
  9. }
  10. ?>


dan zet hij het pas in de database als het goed is 
Gesponsorde links
Dit onderwerp is gesloten.
Actieve forumberichten
© 2002-2025 Sitemasters.be - Regels - Laadtijd: 0.262s