RE: [PHP] Simple If-else statement

2001-03-27 Thread Johnson, Kirk

This code is checking if $fname and $lname are equal to a single blank
character. Is this what you want? My guess is you really want

if(($fname == "") || ($lname == ""))

Another way to write this is

if( (!$fname) || (!$lname) )

Kirk


 -Original Message-
 From: Louis Brooks [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, March 27, 2001 11:34 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Simple If-else statement
 
 
 Hi:
 
 I am trying to set up a simple script that will verify that 
 all the blanks 
 in a form have been filled out and then submit that to mySQL. 
 If the form 
 has not been completely filled out I want it to redirect them 
 back to the 
 original form. I know that the mySQL part of the script 
 works, but I am 
 unable to get the part of the script that checks the form 
 input to see if 
 everything was filled out to work. It seems to bypass this 
 part of the 
 script and enter the info into mySQL . Here is what I have so far:
 
 
 If (($fname == " ") || ($lname == " "))
  {
  header("Location: 
http://callook.org/member_joinform.html");
}else{
 $db = mysql_connect("localhost", "name", "password");
 mysql_select_db("dBase",$db);
 $sql = "INSERT INTO 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Simple If-else statement

2001-03-27 Thread Johannes Janson

Hi,

if ($name == " ") {  checks for a space in $name.
"empty" is either if (§name == "") without a free space
between "" or you could do it with empty($mane)
if (empty($name)) is true if it is empty (who would
have thought this?)

Johannes

"Louis Brooks" [EMAIL PROTECTED] schrieb im Newsbeitrag
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi:

 I am trying to set up a simple script that will verify that all the blanks
 in a form have been filled out and then submit that to mySQL. If the form
 has not been completely filled out I want it to redirect them back to the
 original form. I know that the mySQL part of the script works, but I am
 unable to get the part of the script that checks the form input to see if
 everything was filled out to work. It seems to bypass this part of the
 script and enter the info into mySQL . Here is what I have so far:


 If (($fname == " ") || ($lname == " "))
  {
  header("Location:
http://callook.org/member_joinform.html");
 }else{
  $db = mysql_connect("localhost", "name", "password");
  mysql_select_db("dBase",$db);
  $sql = "INSERT INTO
 members
 (fname,lname,address,city,state,zip,country,email,username,password)
 VALUES

('$fname','$lname','$address','$city','$state','$zip','$country','$email','$
user
 name','$password')";
  $result = mysql_query($sql);
 }

 I hope the formatting comes out right. I am sure it is something simple I
 have missed but I have tried the script several different ways and nothing
 seems to work. Thank you for any help.

 Sincerely,

 Louis Brooks

 BTW: Is there a faq for this list before I go asking anymore questions?




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Simple If-else statement

2001-03-27 Thread Sterling

H-

Another solution might be to use javascript to check the fields before
the page is even submitted to make sure they put "something" in the
first and last name fields. 

Unfortunately I'm not a javascript person but I've seen it done so much
I'm sure you could find examples on the web or via a web search engine. 

As far as your code; I concure with the other posters replies: "" is
empty, " " is a space. I've made the same mistake. Also did the if
($name = "") { } Screwed me up for a bit until I remembered == is
comparison. 8^) Oh well if you don't use it you lose it. 

Take it easy. 
-Sterling


Louis Brooks wrote:
 
 Hi:
 
 I am trying to set up a simple script that will verify that all the blanks
 in a form have been filled out and then submit that to mySQL. If the form
 has not been completely filled out I want it to redirect them back to the
 original form. I know that the mySQL part of the script works, but I am
 unable to get the part of the script that checks the form input to see if
 everything was filled out to work. It seems to bypass this part of the
 script and enter the info into mySQL . Here is what I have so far:
 
 If (($fname == " ") || ($lname == " "))
  {
  header("Location: http://callook.org/member_joinform.html");
 }else{
  $db = mysql_connect("localhost", "name", "password");
  mysql_select_db("dBase",$db);
  $sql = "INSERT INTO
 members
 (fname,lname,address,city,state,zip,country,email,username,password)
 VALUES
 ('$fname','$lname','$address','$city','$state','$zip','$country','$email','$user
 name','$password')";
  $result = mysql_query($sql);
 }
 
 I hope the formatting comes out right. I am sure it is something simple I
 have missed but I have tried the script several different ways and nothing
 seems to work. Thank you for any help.
 
 Sincerely,
 
 Louis Brooks
 
 BTW: Is there a faq for this list before I go asking anymore questions?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Simple If-else statement

2001-03-27 Thread Louis Brooks

Thanks for everyone's response. I am still not able to get the

if(($fname="")) {

statement to work even with the suggestions everyone made so I am beginning 
to wonder if it is a problem with the server. (It is php3 on an Apache 
server. ) Any other suggestions would be greatly appreciated.

Thanks again,

Louis Brooks



At 02:29 PM 3/27/01 -0500, you wrote:
H-

Another solution might be to use javascript to check the fields before
the page is even submitted to make sure they put "something" in the
first and last name fields.

Unfortunately I'm not a javascript person but I've seen it done so much
I'm sure you could find examples on the web or via a web search engine.

As far as your code; I concure with the other posters replies: "" is
empty, " " is a space. I've made the same mistake. Also did the if
($name = "") { } Screwed me up for a bit until I remembered == is
comparison. 8^) Oh well if you don't use it you lose it.

Take it easy.
-Sterling


Louis Brooks wrote:
 
  Hi:
 
  I am trying to set up a simple script that will verify that all the blanks
  in a form have been filled out and then submit that to mySQL. If the form
  has not been completely filled out I want it to redirect them back to the
  original form. I know that the mySQL part of the script works, but I am
  unable to get the part of the script that checks the form input to see if
  everything was filled out to work. It seems to bypass this part of the
  script and enter the info into mySQL . Here is what I have so far:
 
  If (($fname == " ") || ($lname == " "))
   {
   header("Location: 
 http://callook.org/member_joinform.html");
  }else{
   $db = mysql_connect("localhost", "name", "password");
   mysql_select_db("dBase",$db);
   $sql = "INSERT INTO
  members
  (fname,lname,address,city,state,zip,country,email,username,password)
  VALUES
  
 ('$fname','$lname','$address','$city','$state','$zip','$country','$email','$user
  name','$password')";
   $result = mysql_query($sql);
  }
 
  I hope the formatting comes out right. I am sure it is something simple I
  have missed but I have tried the script several different ways and nothing
  seems to work. Thank you for any help.
 
  Sincerely,
 
  Louis Brooks
 
  BTW: Is there a faq for this list before I go asking anymore questions?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Simple If-else statement

2001-03-27 Thread Sterling

H-

Really, that's strange. 

Try printing out your variables and seeing what is actually being
passed. 

print "FNAME:$fname:\n";

With the : : colons surrounding your variable you can see what if
anything is actually in $fname. 

Also it might have been a typo on your part but be sure to check for
single = and double == when using your if statements. 

For debugging purposes do simple stuff first. 

if ($fname == "") { 
print "NOTHING HERE\n";
//header("Location: http://callook.org/member_joinform.html");
} else {
print "Got Something: FNAME:$fname:\n";

if (1 == 2) {
 $db = mysql_connect("localhost", "name", "password");
 mysql_select_db("dBase",$db);
 $sql = "INSERT INTO 
members 
(fname,lname,address,city,state,zip,country,email,username,password) 
VALUES 

('$fname','$lname','$address','$city','$state','$zip','$country','$email','$user 
name','$password')";
$result = mysql_query($sql);
} # end if block commentor for multipe line comments. It's cleaner. 8^)

} end if-else check.

Hope this is helpful. 
-Sterling


Louis Brooks wrote:
 
 Thanks for everyone's response. I am still not able to get the
 
 if(($fname="")) {
 
 statement to work even with the suggestions everyone made so I am beginning
 to wonder if it is a problem with the server. (It is php3 on an Apache
 server. ) Any other suggestions would be greatly appreciated.
 
 Thanks again,
 
 Louis Brooks
 
 At 02:29 PM 3/27/01 -0500, you wrote:
 H-
 
 Another solution might be to use javascript to check the fields before
 the page is even submitted to make sure they put "something" in the
 first and last name fields.
 
 Unfortunately I'm not a javascript person but I've seen it done so much
 I'm sure you could find examples on the web or via a web search engine.
 
 As far as your code; I concure with the other posters replies: "" is
 empty, " " is a space. I've made the same mistake. Also did the if
 ($name = "") { } Screwed me up for a bit until I remembered == is
 comparison. 8^) Oh well if you don't use it you lose it.
 
 Take it easy.
 -Sterling
 
 
 Louis Brooks wrote:
  
   Hi:
  
   I am trying to set up a simple script that will verify that all the blanks
   in a form have been filled out and then submit that to mySQL. If the form
   has not been completely filled out I want it to redirect them back to the
   original form. I know that the mySQL part of the script works, but I am
   unable to get the part of the script that checks the form input to see if
   everything was filled out to work. It seems to bypass this part of the
   script and enter the info into mySQL . Here is what I have so far:
  
   If (($fname == " ") || ($lname == " "))
{
header("Location:
  http://callook.org/member_joinform.html");
   }else{
$db = mysql_connect("localhost", "name", "password");
mysql_select_db("dBase",$db);
$sql = "INSERT INTO
   members
   (fname,lname,address,city,state,zip,country,email,username,password)
   VALUES
  
  ('$fname','$lname','$address','$city','$state','$zip','$country','$email','$user
   name','$password')";
$result = mysql_query($sql);
   }
  
   I hope the formatting comes out right. I am sure it is something simple I
   have missed but I have tried the script several different ways and nothing
   seems to work. Thank you for any help.
  
   Sincerely,
  
   Louis Brooks
  
   BTW: Is there a faq for this list before I go asking anymore questions?
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Simple If-else statement

2001-03-27 Thread Johannes Janson

Hi Louis,

you cuold try it with if (empty($fname)) { redirect...
just check again that your form is ok.

Johannes

"Louis Brooks" [EMAIL PROTECTED] schrieb im Newsbeitrag
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Thanks for everyone's response. I am still not able to get the

 if(($fname="")) {

 statement to work even with the suggestions everyone made so I am
beginning
 to wonder if it is a problem with the server. (It is php3 on an Apache
 server. ) Any other suggestions would be greatly appreciated.

 Thanks again,

 Louis Brooks





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Simple If-else statement - Fixed

2001-03-27 Thread Louis Brooks

Thanks for all the help. I finally got it to work. I ended up using a bunch 
of if ($lname=="") { statements instead of if (($lname=="") || 
($fname=="")) { and that seems to be working. I still can't get the 
header() statement to work. So I just cheated and put in some text telling 
the user to hit the back button and fill out the rest of the information on 
the form.

Louis


At 02:29 PM 3/27/01 -0500, you wrote:
H-

Another solution might be to use javascript to check the fields before
the page is even submitted to make sure they put "something" in the
first and last name fields.

Unfortunately I'm not a javascript person but I've seen it done so much
I'm sure you could find examples on the web or via a web search engine.

As far as your code; I concure with the other posters replies: "" is
empty, " " is a space. I've made the same mistake. Also did the if
($name = "") { } Screwed me up for a bit until I remembered == is
comparison. 8^) Oh well if you don't use it you lose it.

Take it easy.
-Sterling


Louis Brooks wrote:
 
  Hi:
 
  I am trying to set up a simple script that will verify that all the blanks
  in a form have been filled out and then submit that to mySQL. If the form
  has not been completely filled out I want it to redirect them back to the
  original form. I know that the mySQL part of the script works, but I am
  unable to get the part of the script that checks the form input to see if
  everything was filled out to work. It seems to bypass this part of the
  script and enter the info into mySQL . Here is what I have so far:
 
  If (($fname == " ") || ($lname == " "))
   {
   header("Location: 
 http://callook.org/member_joinform.html");
  }else{
   $db = mysql_connect("localhost", "name", "password");
   mysql_select_db("dBase",$db);
   $sql = "INSERT INTO
  members
  (fname,lname,address,city,state,zip,country,email,username,password)
  VALUES
  
 ('$fname','$lname','$address','$city','$state','$zip','$country','$email','$user
  name','$password')";
   $result = mysql_query($sql);
  }
 
  I hope the formatting comes out right. I am sure it is something simple I
  have missed but I have tried the script several different ways and nothing
  seems to work. Thank you for any help.
 
  Sincerely,
 
  Louis Brooks
 
  BTW: Is there a faq for this list before I go asking anymore questions?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



Re: [PHP] Simple If-else statement - Fixed

2001-03-27 Thread Johannes Janson

Hi,

for the haeder just make sure that there is NO output
whatsoever before the header-call. even if line 1 of your
script is empty before the ?php-tag the header doesn't work.


"Louis Brooks" [EMAIL PROTECTED] schrieb im Newsbeitrag
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Thanks for all the help. I finally got it to work. I ended up using a
bunch
 of if ($lname=="") { statements instead of if (($lname=="") ||
 ($fname=="")) { and that seems to be working. I still can't get the
 header() statement to work. So I just cheated and put in some text telling
 the user to hit the back button and fill out the rest of the information
on
 the form.

 Louis






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]