Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Registration Form Validation.

Featured Replies

Hey all,

 

Me and my friend are making a website with a registration system and login system.

 

I'm designing the Registration Form and was wondering how i would do it?

I'm researching a spam bot number thingy to stop it being spammed etc...

But what im really looking for is how a simple example on how to see if required fields are empty and if the email and password fields match, and if the user name is taken, once i got them i think ill be able to figure the rest out myself. Also so when the user clicks the form they don't get a message box saying what they have done wrong but and also the page doesnt change, be nice to have it in bedded so the user sees what they done wrong on the page before they leave it and come back?

 

Sorry if i seem confusing, having a bad day, well couple of weeks really :/ head isnt straight but getting there! :huh:

 

Im looking to do this in php, because i understand it more then Java but if i have to use Java it will be a sample code used instead not a self written code. (prefer self written to expand my knowledge)

 

I'm looking into it now to see what i can do my self, and to get a slight idea on how it is done, but some godly advice would be very appreciated! : ^_^

 

Many Thanks Ben.

Hey all,

 

Me and my friend are making a website with a registration system and login system.

 

I'm designing the Registration Form and was wondering how i would do it?

I'm researching a spam bot number thingy to stop it being spammed etc...

But what im really looking for is how a simple example on how to see if required fields are empty and if the email and password fields match, and if the user name is taken, once i got them i think ill be able to figure the rest out myself. Also so when the user clicks the form they don't get a message box saying what they have done wrong but and also the page doesnt change, be nice to have it in bedded so the user sees what they done wrong on the page before they leave it and come back?

 

Sorry if i seem confusing, having a bad day, well couple of weeks really :/ head isnt straight but getting there! :huh:

 

Im looking to do this in php, because i understand it more then Java but if i have to use Java it will be a sample code used instead not a self written code. (prefer self written to expand my knowledge)

 

I'm looking into it now to see what i can do my self, and to get a slight idea on how it is done, but some godly advice would be very appreciated! : ^_^

 

Many Thanks Ben.

 

http://fifa09ladders.site90.net/register.php

 

Hi

 

The form above was modified by myself, and has certain flaws, eg if you do not specify a username or password it will still register blank fields, which in turn will allow almost anyone to access your secure pages without registering

 

The form below has been modified to sort this out.

 

All fields are now required, it will check the username is available, encode the password to md5 and e-mail the user his registration details.

 

Rookie-racer, please update your file to the below adding the fields you require.

 

Cheers

 

Pat

 

<?PHP



$dbhost = " ";
$dbname = " ";
$dbuser = " ";
$dbpass = " ";



mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());


$name = $_POST['name'];
$email = $_POST['email'];
$username = $_POST['username'];
$password = md5($_POST['password']);

if (!$username || !$password || !$name || !$email) {
echo "Please fill in all the required fields.";
include 'register.html';
 exit();
}

$checkuser = mysql_query("SELECT username FROM members WHERE username='$username'");

$username_exist = mysql_num_rows($checkuser);

if($username_exist > 0){
 echo "I'm sorry but the username you specified has already been taken.  Please pick another one.";
 unset($username);
 include 'register.html';
 exit();
}



$query = "INSERT INTO members (name, email,  username, password )
VALUES('$name', '$email',  '$username', '$password')";
mysql_query($query) or die(mysql_error());
mysql_close();

echo "You have successfully Registered";



$yoursite = "yoursite";
$webmaster = "admin";
$youremail = "me@me.co.uk";

$subject = "You have successfully registered at $yoursite...";
$message = "Dear $name, you are now registered at our web site.  
 To login, simply go to our web page and enter in the following details in the login form:
 Username: $username
 Password: $password

 Please print this information out and store it for future reference.

 Thanks,
 $webmaster";

mail($email, $subject, $message, "From: $yoursite <$youremail>\nX-Mailer:PHP/" . phpversion());

echo "Your information has been mailed to your email address.";

?>

  • Author

Hey all,

 

Thanks for the replys im currently waiting for our hosting to get sorted out then ill say if it works etc.

 

Many Thanks again

 

Ben

 

P.S with php code can someone explain to me what the symbols are for equal to or not equal to and and or please? Thanks

 

I gather greater then is > and less then is <

== equal to

!= not equal to

< less than

> greater than

=< smaller than or equal to

=> bigger than or equal to

 

also i recommend using both php and javascript for validation. php being there just for backup cuz javascript is client side it can just be turned off. however if it is used how it should, your form can be validated without a page refresh, which imo is better

  • Author
== equal to

!= not equal to

< less than

> greater than

=< smaller than or equal to

=> bigger than or equal to

 

also i recommend using both php and javascript for validation. php being there just for backup cuz javascript is client side it can just be turned off. however if it is used how it should, your form can be validated without a page refresh, which imo is better

 

 

If i use both Javascript and Php for validation would the java be best used internaly on the page and then the php in an external file just to double check if java is turned on and if java is turned off its still there to validate?

 

And I can use javascript to do it without a page refresh which is what i would prefer to start with?

 

Ill have a look into some java validation aswell, i know dreamweaver has java validation built in but thats nothing special now is it?

 

Ben

As red-x has said, javascript can be turned off by the user so you need to validate again with php upon submission.

Javascript validation is worth having though as it can give immediate feedback to the user without refreshing the page and therefore saving your server the effort.

A simple example of javascript validation would look like this.

If javascript is turned off, the form data is still validated by process.php (which doesn't exist btw).

Hope that helps :)

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.