This is a discussion on "Functions and conditional IFs" within the PHP Forum section. This forum, and the thread "Functions and conditional IFs are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Functions and conditional IFs
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
Functions and conditional IFs
I am having a problem with the IF statements in my functions.
What I am trying to do is when the page first loads, the form is prefilled with values from the database. If the user makes a change to one of the fields and it doesn't validate, the field is rest to the value from the database. I have that part working where the values are put in the form on page load and the errored field has the dtabase value put back in, but if all the other valid fields have their variables wiped and the fields are empty. The problem I think is with these functions
|
|
|
|
#2
|
||||
|
||||
|
Re: Functions and conditional IFs
I think the problem you are having is because you are only setting the index for each field if there is an error.
eg. $error['last_name'] will only exist if there is a problem with it. When you're checking to see if there has been an error you can try if (!empty($error['last_name'])) { //etc } Depending of your PHP version, this may be throwing a notice that is messing the rest up? If that's not it, what does the function check_input() do? Cheers,
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
#3
|
|||
|
|||
|
Re: Functions and conditional IFs
check_input() is a function that cleans the user input such as mysql_real_escape_string
I will check that suggestion of yours becuase it is the best thing that I haven't tried |
|
#4
|
|||
|
|||
|
Re: Functions and conditional IFs
I have checked the logs and I am getting these notices
Quote:
|
|
#5
|
||||
|
||||
|
Re: Functions and conditional IFs
Hi Adrock,
You would be getting this error for the same reason as before -- the error field won't actually be there unless the error occured. You should probably check for the error's existence using if (!empty($error[$field])) { // etc.. Unless you know for certain the arraay key will be there. Cheers
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Using Type Input in Conditional Statement | affirmallchance | Flash & Multimedia Forum | 3 | Jan 9th, 2008 11:30 |
| [SOLVED] conditional statement firefox | saltedm8 | Web Page Design | 9 | Nov 25th, 2007 18:13 |
| [SOLVED] How do I write IE conditional comment | Lchad | Web Page Design | 23 | Oct 17th, 2007 01:29 |
| Conditional IF in external stylesheet | AdRock | Web Page Design | 6 | Sep 23rd, 2007 22:45 |
| ASP stylesheet switcher with conditional comments | Shelly | Classic ASP | 1 | Apr 19th, 2006 12:44 |