Re: Comma separated list

David McGlone <[email protected]>
Newsgroups gmane.comp.php.database
Message-ID <2654341.1PNGMxl4I7@buddy>
On Saturday, August 25, 2012 10:19:20 PM Karl DeSaulniers wrote:
> $errors = "";
> foreach($_POST as $key=>$val) {
> 	if(empty($val)) {
> 		$errors .= "Please enter ".$key."<br>";
> 	}
> }
> if($errors !== "") { //or check string length here
> 	return $errors;
> } else {
> ...
> 
> then if they need individual checking like password or email I don't
> have to check to see if they are empty.

Thanks Karl. This is something good for me to ponder over. I'm going to play 
around with the concept and see what I come up with.

David M.

> 
> Best,
> Karl
> 
> On Aug 25, 2012, at 8:15 PM, David McGlone wrote:
> > Hi all
> > 
> > I've moved on to learning checking forms for valid imput and when
> > doing thing
> > that are repetive, like
> > 
> > if ($_POST['first'] == "") {
> > 
> >       $errors .= 'Please enter a valid name.';
> >     
> >     }
> > 
> > if ($_POST['second'] == "") {
> > 
> >       $errors .= 'Please enter a valid name.';
> >     
> >     }
> > 
> > I can think of a slightly better way like
> > 
> > if($_POST['first'] || $_POST['second'] || $_POST['third'] ==){
> > bla bla
> > }
> > 
> > I think I could also use empty(), not sure though, But I belive
> > there are much
> > easier ways. What would anyone here do?
> > 
> > If it were me, I'd use the one that uses the or operator.
> > 
> > David M.
> 
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.