style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif" ;
color:windowtext'> &=
nbsp; I
need help in in validating a form.
style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif" ;
color:windowtext'> &=
nbsp; The
for is valdated be a javascript frist then if all the fields are filled =
in its
valaded be PHP.
style=3D'font-size:11.0pt;
font-family:"Calibri","sans-serif";color:windowtext'>The =
“formValidator()”
goes to a javascript and does display the missing information in this =
case BUT
then the page gets reloaded and clears all the javascript error messages =
and
does the PHP validation.
style=3D'font-size:11.0pt;
font-family:"Calibri","sans-serif";color:windowtext'>Without puting on =
numeric
lines of go can you suggest things I must have overlooked. Silly request =
but
there must be something I’m overlooking. I have =
simular
code on other programs but this one is casuing me =
trouble.
"then the page gets reloaded and clears all the javascript error messages
and does the PHP validation."
That is because the form is getting submitted... make sure you js code
prevents form submit if errors are found....
Midhun Girish
On Mon, Dec 21, 2009 at 8:13 AM, Ernie Kemp wrote=
:
> Good Day,
>
>
>
> I need help in in validating a form.
>
> The for is valdated be a javascript frist then if all the
> fields are filled in its valaded be PHP.
>
>
>
> The Form starts with:
>
>
> $_SERVER['PHP_SELF'];?>" method=3D"post" onsubmit=3D'return formValidator=
()' >
>
>
>
> The =93formValidator()=94 goes to a javascript and does display the missi=
ng
> information in this case BUT then the page gets reloaded and clears all t=
he
> javascript error messages and does the PHP validation.
>
>
>
> The PHP only runs if the fields are set by testing using =91isset=94.
>
>
>
> Without puting on numeric lines of go can you suggest things I must have
> overlooked. Silly request but there must be something I=92m overlooking. =
I
> have simular code on other programs but this one is casuing me trouble.
>
>
>
> Thanks every so much..
>
>
>
> ....../Ernie
>
>
>
>
>
>
>
>
>
>
>
Does the js function return false on the errors to block the submission?
Bastien
Sent from my iPod
On Dec 20, 2009, at 9:43 PM, "Ernie Kemp" =20
wrote:
> Good Day,
>
>
>
> I need help in in validating a form.
>
> The for is valdated be a javascript frist then if =20
> all the fields are filled in its valaded be PHP.
>
>
>
> The Form starts with:
>
>
> ['PHP_SELF'];?>" method=3D"post" onsubmit=3D'return formValidator()' >
>
>
>
> The â=9CformValidator()â=9D goes to a javascript and does =
display the =20
> missing information in this case BUT then the page gets reloaded and=20=
> clears all the javascript error messages and does the PHP validation.
>
>
>
> The PHP only runs if the fields are set by testing using â=98isset=E2=
.
>
>
>
> Without puting on numeric lines of go can you suggest things I must =20=
> have overlooked. Silly request but there must be something Iâ=99m =
overl=20
> ooking. I have simular code on other programs but this one is cas=20=
> uing me trouble.
>
>
>
> Thanks every so much..
>
>
>
> ....../Ernie
>
>
>
>
>
>
>
>
>
>
--Apple-Mail-1--378752498--
Re: Form validation issue
am 21.12.2009 17:03:50 von TedD
At 9:43 PM -0500 12/20/09, Ernie Kemp wrote:
>Good Day,
>
> I need help in in validating a form.
> The for is valdated be a javascript frist then if
>all the fields are filled in its valaded be PHP.
>
> The Form starts with:
>
Re: Form validation issue
am 24.12.2009 10:40:41 von kranthi
The javascript function formValidator() must return false if any
errors are formed.
>>The PHP only runs if the fields are set by testing using =91isset=94.
You should definitely have a better validation than that. Remember
that all users dont have javascript enabled. Moreover it is very easy
to modify the request variables.
>> However, if the server-side evaluation fails and the page is refreshed, =
then all the previous values are lost -- UNLESS -- you keep them in a cooki=
e, database, or session. I suggest using a session.
This is true when the page is refreshed but I doubt that is the case
here. Since $_SERVER['PHP_SELF'] is being used I think value=3D"
echo $_POST[...] ?>" will be sufficient
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
If you are using a post method using $_SERVER['PHP_SELF'], then values are
present in the POST array, hence, you would write your html with
interspersed php like so:
I sometimes use a function for the echoing of these values if I use the same
form for first time (ie. registration) and editing (update), and the
function checks for a $_POST value, then secondly for an existing database
value variable (ie. $row['username']). If either exist, populate the input
with it (precedence given to POST), otherwise it is empty.
The function looks something this:
function echoValue($post=null, $row=null) {
if (isset($post)) {
echo $post;
} elseif (isset($row)) {
echo $row;
}
}
and is used like this:
after performing a query on a query-string variable (eg. profile.php?id=57
---> 'SELECT * FROM `users` WHERE `id` = '.$_GET['id'] ) etc.
On Mon, Dec 21, 2009 at 8:03 AM, tedd wrote:
> At 9:43 PM -0500 12/20/09, Ernie Kemp wrote:
>
>> Good Day,
>>
>> I need help in in validating a form.
>> The for is valdated be a javascript frist then if all the
>> fields are filled in its valaded be PHP.
>>
>> The Form starts with:
>>
Re: Form validation issue
am 24.12.2009 16:15:43 von TedD
At 2:22 AM -0800 12/24/09, Allen McCabe wrote:
>Tedd,
>
>If you are using a post method using $_SERVER['PHP_SELF'], then
>values are present in the POST array, hence, you would write your
>html with interspersed php like so:
>
>
>id="username" />
No, I wouldn't do it that way.
First, a "post method using $_SERVER['PHP_SELF']" is the same as
action="". A form by default, defaults to itself and thus no need for
$_SERVER['PHP_SELF'].
Second, I seldom use any POST variable without sanitizing it first.
As such, my statements always look like --
-- where the variable $user_name has been"sanitized" in some fashion
(i.e., trim, limit length, etc.).
I think that is easier to read and debug. Also, if I am using a
javascript routine (as mentioned in the OP), then I add '
id="user_name" '
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Form validation issue
am 24.12.2009 16:21:37 von TedD
At 3:10 PM +0530 12/24/09, kranthi wrote:
>The javascript function formValidator() must return false if any
>errors are formed.
>
>>>The PHP only runs if the fields are set by testing using 'isset".
>You should definitely have a better validation than that. Remember
>that all users dont have javascript enabled. Moreover it is very easy
>to modify the request variables.
>
>>> However, if the server-side evaluation fails and the page is
>>>refreshed, then all the previous values are lost -- UNLESS -- you
>>>keep them in a cookie, database, or session. I suggest using a
>>>session.
>This is true when the page is refreshed but I doubt that is the case
>here. Since $_SERVER['PHP_SELF'] is being used I think value="
>echo $_POST[...] ?>" will be sufficient
I forgot to mention that $_POST does hold on to the values as well --
so, one could use that. However, you still have to repopulate the
form and that was what I was getting at.