length validation error

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
olly86
-


Joined: 25 Apr 2003
Posts: 993
Location: Wiltshire, UK

PostPosted: Sun Sep 26, 2004 4:20 pm    Post subject: length validation error Reply with quote

the following elseif statement is triggered for any combination of letters, and will only work if more than 1 number is entered:
Code:
elseif ($_POST['password'] <5) {
     $_SESSION['error']='your password is too short. Please try again!';
     header("Location: account.php?action=register&process=password");
}

I need this if statement to be triggered only if the $_POST['password'] variable contains less than 5 characters.

thanks in advance
_________________
Olly
Back to top View user's profile Send private message
k1ll3rdr4g0n
-


Joined: 04 Jul 2004
Posts: 609

PostPosted: Sun Sep 26, 2004 4:56 pm    Post subject: Reply with quote

Oh man thats mind boggling... woudlnt it be something like

Code:

elseif ($_POST['password'] <5 [b]char[/b]) {
     $_SESSION['error']='your password is too short. Please try again!';
     header("Location: account.php?action=register&process=password");
}
[/b]
_________________
Back to top View user's profile Send private message AIM Address
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Sun Sep 26, 2004 8:24 pm    Post subject: Reply with quote

I think you setup your ifelse wrong , try this example here.

Code:

<?php
if ($_POST['password'] < 5) {
$_SESSION['error']='your password is too short. Please try again!';
}else{
header("Location: account.php?action=register&process=password");
}
?>
Back to top View user's profile Send private message Visit poster's website
olly86
-


Joined: 25 Apr 2003
Posts: 993
Location: Wiltshire, UK

PostPosted: Sun Sep 26, 2004 8:44 pm    Post subject: Reply with quote

thanks for all the advice, but this is what I've found that works instead:
Code:
elseif (strlen($_POST['password']) <5) {
   $_SESSION['error']='your password is too short. Please try again!';
   header("Location: account.php?action=register&process=password");
}

_________________
Olly
Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group