/    Sign up×
Community /Pin to ProfileBookmark

Small fix needed… please help

Hi, i have some form validation on a small page that i have. It checks that the fields A, B, C & D are are not empty. However i want to have validation on the D field to make sure that only the values 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 are allowed only and not 11, 12… or not 01, 02… – only the scores 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

Here is the code i have now:

[code=php]set_flashIf( empty($_POST[‘everyhit’]), ‘Ooops… Please fill in the everyhit field’);
set_flashIf( empty($_POST[‘birthday’]), ‘Ooops… Please fill in the birthday field’);
set_flashIf( empty($_POST[‘youtube’]), ‘Ooops… Please fill in the youtube field’);
set_flashIf( empty($_POST[‘rate’]), ‘Ooops… Please fill in the rate field’);
redirectIf(flash_exists(), ‘moderator/index.php?’. $_SERVER[‘QUERY_STRING’]);[/code]

Can someone please add on the code needed for this as i need to fix it urgently, thanks for your help

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@CrucialOct 19.2007 — I have no idea what set_flashIf() is doing or where it is coming from.

Here is a basic less than test - insert as needed.

$allow_d_variable = false;

if($_POST['rate'] < 11) {

$allow_d_variable = true;

}

if the variable is "01" you can change it 1 with settype

settype($_POST['rate'] , "integer");
×

Success!

Help @oo7ml spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...