Server-side validation with PHP

Introduction

In the previous article Hacking around with JavaScript we have looked at some techniques that can be used to bypass client-side (JavaScript) validation.  Although beneficial, client-side validation is not that reliable and should be utilized more as a usability rather than security feature. Having one in place does not eliminate the need for the server-side validation.

For the purpose of this article we will set up a simple MySQL table to store user registration data, design a user registration form and write some PHP code to validate user’s input.

$2.89
- OR -

Overview

Setting up MySQL table

Using your MySQL management tool you can use the following SQL statement to create the table for storing our registration data.

CREATE TABLE `reg_users` (

`USER_ID` INT NOT NULL AUTO_INCREMENT ,
`First_Name` VARCHAR( 15 ) NOT NULL ,
`Last_Name` VARCHAR( 15 ) NOT NULL ,
`User_Name` VARCHAR( 20 ) NOT NULL ,
`Password` VARCHAR( 20 ) NOT NULL ,
`Email` VARCHAR( 50 ) NOT NULL ,
`Web_Site` VARCHAR( 150 ) ,
`Signature` VARCHAR( 255 ) ,
`Birthday` DATE,
PRIMARY KEY ( `USER_ID` )

);

This will create the table “reg_users” with 9 fields.

Alex July

Alex JulyAlex July is a Vancouver-based (Canada, British Columbia) Web Developer/ Graphic Artist who has an extensive experience in both creative realms.
He is also a host of Linecraft.com where he is showcasing his skills and sharing experience with the developers community. For the past 3 years Alex has been focusing on the development of Rich Internet Applications using Macromedia Flash technology.

When away from the computer Alex is practicing Martial Arts, playing guitar and enjoying time with his wonderful family.

See All Postings From Alex July >>

Reviews

Be the first to write a review

You must me logged in to write a review.