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
https://forums.phpfreaks.com/topic/93212-registration-form-validation-help-please/
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…………………



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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.