View Single Post
05-29-2009, 02:54 AM
#4
travmanx is offline travmanx
Status: I'm new around here
Join date: May 2009
Location:
Expertise:
Software:
 
Posts: 2
iTrader: 0 / 0%
 

travmanx is on a distinguished road

  Old

As pixolio stated above, using the NULL is the best way to approach this.

Here are 3 solutions

Code:
if($_POST['name']==NULL || $_POST['gender']==NULL || $_POST['dob']==NULL || $_POST['email']==NULL || $_POST['telephone']==NULL || $_POST['comment']==NULL)
Here's how I would approach:
Code:
if(!$_POST){ //Saves the user computer time (not alot)
if(!$_POST['name'] || !$_POST['gender'] || !$_POST['dob'] || $_POST['email'] || $_POST['telephone'] || !$_['comment']){
echo 'Some or all the fields were left blank';
}
echo 'All fields left blank';
}
and finally probably the most simple way but not sure how effective against attacks and vulns

Code:
$array = $_POST; //since $_POST is an array
foreach($array as $k => $v){
if(!$v) { //You can use $v = NULL or $v = ''
return('A required field was left blank');
}
Hope this helps.

Reply With Quote