Form Validation - Specific Number

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
johnsqftwr
Forum Newbie
Posts: 3
Joined: Sun Mar 15, 2009 5:58 am

Form Validation - Specific Number

Post by johnsqftwr »

Hi,

I have a simple php update form which allows teams to update their results.

They enter the score and then I have I have 5 fields:
Win
Lose
Draw
Tie
Cancel

I require the teams to only enter the number 1 in one of these fields.
I need to allow only null or 1 for each field and then, I assume the best way is to have a hidden field that sums to total of the 5 fields and ensures that the total of the 5 fields is less than 2

I am new to PHP, so any help with the code would be greatly appreciated.


John
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Form Validation - Specific Number

Post by Benjamin »

Have you written any PHP code? I'd like to help you but I really don't want to write it for you from scratch.
johnsqftwr
Forum Newbie
Posts: 3
Joined: Sun Mar 15, 2009 5:58 am

Re: Form Validation - Specific Number

Post by johnsqftwr »

Many thanks for reply.

I am new to php and the only code that I have has been generated by Dreaweaver.

For example:
<input type="text" name="Win" value="<?php echo htmlentities($row_rsResults['Win'], ENT_COMPAT, 'utf-8'); ?>" size="2" />

Coulld you could point me in the right direction?
jh_1981
Forum Newbie
Posts: 22
Joined: Fri Jan 30, 2009 6:21 pm

Re: Form Validation - Specific Number

Post by jh_1981 »

use regular expression
Post Reply