Ezilon.com - Target Your Audience, be Seen in Your Region

isset & fwrite

You are viewing this site as a guest. Join our community to get your questions answered and share knowledge. Active members may advertise and ask for a website critique.

They have: 1 posts

Joined: Aug 2008

Simple problem. I have a form where I fill in the value of $ing1 & $ing2. Then it's sent to page witch creates another page but containig the values from the form page.
This part of the script should check if I entered $ing1 and when I would, it should write all dose thing.(fwrite and all)...if not it should leave out the fwrite things and go to the second if(ing2),or fwrite all those thing and go to the second $ing2...can any one tell me what I'm doing wrong??because it's not working

if (isset($ing1))
{
fwrite($file,'$ing1');fwrite($file,'');fwrite($file,'');
}
else {break;}

if (isset($ing2))
{
fwrite($file,'$ing2');fwrite($file,'');fwrite($file,'');
}
else {break;}

teammatt3's picture
Moderator

He has: 1,902 posts

Joined: Sep 2003

Is $ing1 being assigned from some request variable (GET or POST)? If that's true, then no matter what, $ing1 will always be set. That means isset() will always return true, which is not the behavior you're looking for. You should probably use !empty() or strlen() to determine if a user entered a value.