Re: Hold that insert!
| From: | Darryl Friesen | Date: | Tue, 27 Mar 2001 16:33:49 +0000 |
| Subject: | Re: Hold that insert! | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-7882@lists.php.net to get a copy of this message | ||
> I have the insertRecord function which is supposed to be called only
> when you hit submit. For some reason I'm blanking out on how to do
> this. The function and function call ARE on the same page. I think I
> just need some logic to indicate "stop" and "go".
Every form has a submit button right? Submit buttons are form elements
(whose value is submitted when the button is clicked), just like any other
form field. So I have something like this:
<INPUT NAME="submit" TYPE="submit" Value=" Click Here! ">
In my PHP code, I check the value of $submit; if it's empty, I know the form
data hasn't been submitted yet (if it had, $submit would have the value "
Click Here! "), so in that case I display the form. If it does not have an
empty value, the user has clicked the submit button, so I can go ahead
processing the form data. Like this:
if ( empty($submit) )
{
### Display the form
}
else
{
### Do some checks to make the the data is OK
### Do the Insert, or whatever else is to be done
}
- Darryl
----------------------------------------------------------------------
Darryl Friesen, B.Sc., Programmer/Analyst Darryl.Friesen@usask.ca
Education & Research Technology Services, http://gollum.usask.ca/
Department of Computing Services,
University of Saskatchewan
----------------------------------------------------------------------
"Go not to the Elves for counsel, for they will say both no and yes"