burge124 Posted February 26, 2008 Share Posted February 26, 2008 hi, ive got this basic registration form, want to do checks form to ensure that there legit etc before entering to db... make sure all feilds contain something empty() function check entered an email address's contains an "@" and "." or output an error message check to see if there already a memeber by checking email address then refuse & output an error message check both passwords are identical conform to being sent emails/sent group emails (make sure checkbox is ticked) whats the best way of solving this? an incremented count? true/false statments or if else statments? i would also like to stop form from being submitted until all of the form is correct and therefore output single or multiply error messages when the page refreshes to indicate to the user where they have gone wrong heres the code... <input type="text" name="UserName" /> <input type="password" name="Password" /> <input type="password" name="Password2" /> <input type="text" name="Email" /> <input name="grant" type="checkbox" id="grant" value="checkbox" /> <input name="submit" type="submit" class="subHeader" id="submit" value="Submit" /> <input name="reset" type="reset" class="subHeader" onclick="reset(); return false;" value="Refresh" /></td> thanks Quote Link to comment Share on other sites More sharing options...
burge124 Posted February 26, 2008 Author Share Posted February 26, 2008 im reading into Spry validation and widgets is that the right direction? Quote Link to comment Share on other sites More sharing options...
cyrixware Posted February 27, 2008 Share Posted February 27, 2008 I see. Try this one: <script language="JavaScript"> function form_validator(theForm) { if(theForm.Password.value == "") { alert("Please enter your password!"); theForm.Password.focus(); return(false); } if(theForm.Password2.value == "") { alert("Please confirm your password!"); theForm.Password2.focus(); return(false); } if(theForm.Password.value != theForm.Password2.value ) { alert("Password did not matched"); theForm.Password2.focus(); return(false); } } </script> <form onSubmit="return form_validator(this)" name="form" id="form" method="post" action="register.php"> <input type="text" name="UserName" /> <input type="password" name="Password" /> <input type="password" name="Password2" /> <input type="text" name="Email" /> <input name="grant" type="checkbox" id="grant" value="checkbox" /> <input name="submit" type="submit" id="submit" value="Submit" /> <input name="reset" type="reset" class="subHeader" onclick="reset(); return false;" value="Refresh" /></td> <?php $submit = $_REQUEST['Submit']; if($submit == "Submit") { if ((!$_POST[userName]) || (!$_POST[Password])|| (!$_POST[Password2]) || (!$_POST[Email]) || (!$_POST[checkbox])) { ?> <script language="JavaScript"> win = window.open('register.php','_self'); </script> <?php exit; } Insert Codes here………………… Quote Link to comment Share on other sites More sharing options...
cyrixware Posted February 27, 2008 Share Posted February 27, 2008 After that create a code to get the @ and . in the email textbox. Then SELECT in the dbase if that email address exist. Try modify that source codes. The easiest way to do is use the if else statements. But still its up to you. Regards Quote Link to comment Share on other sites More sharing options...
cyrixware Posted February 27, 2008 Share Posted February 27, 2008 You can use the javascript or the $_POST['Field'] to see if the textbox is emtpy or not. For more info about String / Substr try to visit php.net. Quote Link to comment 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.