Re: Passing Form As Argument

From: Date: Fri, 21 Apr 2006 14:15:17 +0000
Subject: Re: Passing Form As Argument
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-234492@lists.php.net to get a copy of this message
At 3:46 PM -0700 4/20/06, Chris Kennon wrote:
I'm new to the list so "Hello" to all. I'm drafting a function.php page, which will be included() in the pages in need. How would I pass a form as an argument of a function? From the name parameter of the form element or perhaps an ID: function checkForm(theForm){ //Form validation code omitted. }
You can't pass the form, but you can pass the form content, which is probably what you want anyway. If it were me, I would place a form value ($theForm) in each fomr as a <input> hidden variable that would identify which form and I would pass that to your checkForm($theFrom) function. From there, I would set up a switch which would channel your validation. The variables to validate, of course, would be in your $_POST or $_GET arrays. That should be simple enough.
Also, I seem to recall some caution is needed when using user-defined functions?
No more so than any other syntax, just do it right. tedd -- -------------------------------------------------------------------------------- http://sperling.com

« previous php.general (#234492) next »