Topic awaiting preservation: PHP help please... (Page 1 of 1) |
|
---|---|
Paranoid (IV) Mad Scientist From: A lost remnant |
posted 05-28-2002 06:53
I'm trying to get a PHP script to write to a database and check whether or not a form element has been filled out, my problem is that if the form has not been filled out it will write a row to the database anyway without any information. I don't know how to write a statement that would say if the element has been filled out then write to the database once the script has the information. Any Help would be much appreciated. |
Maniac (V) Mad Scientist From: Belgrade, Serbia |
posted 05-28-2002 08:04
Your switch statement is wrong. The correct syntax is: |
Paranoid (IV) Mad Scientist From: A lost remnant |
posted 05-28-2002 19:48
Thanks Max! Your tips helped out very much. But for some reason I couldn't get the if statement to work in place of the switch statement without getting a parse error. |
Paranoid (IV) Inmate From: Minneapolis, MN, USA |
posted 05-28-2002 20:39
Is all your code here? Because it seems like stuff is missing. For one thing, I don't see the update_database() function declared anywhere. |
Paranoid (IV) Mad Scientist From: A lost remnant |
posted 05-29-2002 10:25
Jiblet, |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 05-29-2002 19:07
Alright this is where a class is called for. Here I whipped this up code: <?
|
Paranoid (IV) Inmate From: Minneapolis, MN, USA |
posted 05-29-2002 19:57
All I can say about that code snippet is that it will only work if $phoneone, $phonetwo, and $phonethree are all empty. Of course, it's probably an invalid phone number if ANY of the fields are missing, which is why I suggested using | | rather than &&. |
Paranoid (IV) Inmate From: Harrow, Ontario, Canada |
posted 05-30-2002 20:11
When I need to check a form for errors, I use an array called $errors, and use a bunch of if statements. Like this: |
Paranoid (IV) Mad Scientist From: A lost remnant |
posted 06-04-2002 03:14
I just wanted to say thanks for all of the help. (I know its a bit late) but I wanted to take a break from the computer for awhile. I will probably study the scripts posted and see if I can figure out how they work a bit later on once I figure out how to make this stupid If statement work *arg* lol. Thanks for all of the help though, I much appreciate it. |