Form validation

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
eshban
Forum Contributor
Posts: 184
Joined: Mon Sep 05, 2005 1:38 am

Form validation

Post by eshban »

Hi , i have a simple, i want to apply a validation so that user cannot cannot leave any field blank.

means when user press the submit button, the form will transfer the control back, and highligh the text or anything which shows, that "that field" is missing.

how can i do that

plz reply

eshban
mickd
Forum Contributor
Posts: 397
Joined: Tue Jun 21, 2005 9:05 am
Location: Australia

Post by mickd »

Weirdan | Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
easy way is to have the form go back to the same page and have the validation code in the same page at the top

other way is to use sessions to store the data check it and then display it back.

Code: Select all

if(empty($_POST['fieldname'])) {
$empty = 1;
}

// form

if($empty == 1) {
echo 'field empty';
} // thats the easy concept behind it.
Weirdan | Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Post Reply