Jump to content

registration form validation help please!


burge124

Recommended Posts

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

Link to comment
Share on other sites

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…………………



Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.