/    Sign up×
Community /Pin to ProfileBookmark

post check with 2 posibilities

Hi,

I Have the following issue.
In my form I have a field that doesn’t need to be filled, but if it does it needs to have a value that is 5 or higher.

Currently it is being checked on a value lower then 5

[code=php]
if ($_POST[‘value’] < 5){
$error .= “Error melding.”;
}else{
$code .= $_POST[‘value’];
}
[/code]

I thought to fix this with a elseif statement, but this doesn’t work. Probably because I do it wrong

[code=php]
if ($_POST[‘value’] < 5){
$error .= “Error melding.”;
}elseif (!empty $_POST[‘value’]){
$code .= $_POST[‘value’];
}
else{
$code .= $_POST[‘value’];
}
[/code]

Any ideas?
Thnx

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@Interactive1984authorMar 28.2013 — I got if fixed.

For the ones that are wondering how:

[code=php]
if( !isset( $_POST['value'] ) || '' === trim( $_POST['value'] ) )
{
// nothing filled
}
elseif( 5 > $_POST['value'] )
{
// Number to low
}
else
{
// Allright
}
[/code]
×

Success!

Help @Interactive1984 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 5.17,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...