I've been turning a blind eye to this problem for ages, but I've finally reached a point where it's cracking me up.
Basically, I'm increasingly being plagued with instances where the most fundamental PHP statements are absolutely NOT behaving as they should.
To give a concrete example...
Let's say I've got a form that I want people to fill in. And, let's say that the form has range of fields such as Name, Email address, Description and so on. Now, if all of the values in the form have been filled in then COOL- the script can enter the info into a database and all is well.
But, let's imagine that a person accidentally forgets to fill out the field called "Full Description" that's on the form. Well, in that case the script should simply realise that the Full Description ($fulldesc) is empty and display an error message.
But it's just not working for me! 🙁
I shall end this thread with a snippet of my code. To paint the picture, the code I'm showing is on the page that has received the information from the form. So, imagine that somebody has just filled out an HTML form with fields call "item_nam", "item_pirc" and so on. The code below is on the page that has received these raw variables...
$itemname=ucfirst(addslashes(strip_tags(trim($_POST[item_nam]))));
$itemprice=$_POST[item_pric];
$itemprice = ereg_replace("[^.[:digit:]]", "", $itemprice);
$itemimage="defaultpic.gif";
$shortdesc=ucfirst(addslashes(strip_tags(trim($_POST[shortdesc]))));
$smallpic="defaultsmallpic.gif";
$category=addslashes($_SESSION[cate]);
$shipping=$_POST[postandp];
$shipping = ereg_replace("[^.[:digit:]]", "", $shipping);
$fulldesc=ucfirst(addslashes(strip_tags(trim($_POST[fulldesc]))));
$_SESSION[itemname]=$itemname;
if ($itemname && $itemprice && $itemimage && $shortdesc && $smallpic && $category && $shipping && $fulldesc !=="") {
//enter the stuff into the MySQL table and move on
}
The problem is... EVEN IF no full description ($fulldesc) has been filled in, the script goes ahead and enters data into the table.
Any help would be mega appreciated.