Check for empty fields script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
crazymao
Forum Newbie
Posts: 14
Joined: Sun Aug 02, 2009 1:56 pm

Check for empty fields script

Post by crazymao »

ok so i have created a form which checks for empty fields

if (empty($username) || empty($password)) {
include "loginpage.php";
echo "Please fill in all the fields";
} else {

but the problem is that even if i fill in all the fields it still gives my the message.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Check for empty fields script

Post by jackpf »

What's the whole script?
Haddman
Forum Newbie
Posts: 8
Joined: Tue Aug 04, 2009 9:01 pm

Re: Check for empty fields script

Post by Haddman »

It would be better to see a bit more of the script but try this:

Code: Select all

 
if(!isset($_POST['username']) || !isset($_POST['password'])){
 echo "Please fill in all the fields";
}else{
........
 
Post Reply