Form validation issue

------=_NextPart_000_0001_01CA81BD.7E39F510
Content-Type: multipart/alternative;
boundary="----=_NextPart_001_0002_01CA81BD.7E3A9150"


------=_NextPart_001_0002_01CA81BD.7E3A9150
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit



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:

<form name="myForm" action="<?php echo
$_SERVER['PHP_SELF'];?>" method="post" onsubmit='return formValidator()' >



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.



The PHP only runs if the fields are set by testing using 'isset".



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.



Thanks every so much..



......./Ernie












------=_NextPart_001_0002_01CA81BD.7E3A9150
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:dt=3D"uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" =
xmlns=3D"http://www.w3.org/TR/REC-html40">

<head>
<meta name=3D"Microsoft Theme 2.00" content=3D"rmnsque 011">
<meta http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
[at] font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
[at] font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
[at] font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
[at] font-face
{font-family:"Book Antiqua";
panose-1:2 4 6 2 5 3 5 3 3 4;}
[at] font-face
{font-family:"Ancestory SF";
panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Calibri","sans-serif";
color:black;}
h1
{mso-style-priority:9;
mso-style-link:"Heading 1 Char";
margin-top:24.0pt;
margin-right:0cm;
margin-bottom:0cm;
margin-left:0cm;
margin-bottom:.0001pt;
page-break-after:avoid;
font-size:16.0pt;
font-family:"Calibri","sans-serif";
color:black;}
h2
{mso-style-priority:9;
mso-style-link:"Heading 2 Char";
margin-top:10.0pt;
margin-right:0cm;
margin-bottom:0cm;
margin-left:0cm;
margin-bottom:.0001pt;
page-break-after:avoid;
font-size:14.0pt;
font-family:"Calibri","sans-serif";
color:black;
font-weight:normal;}
h3
{mso-style-priority:9;
mso-style-link:"Heading 3 Char";
margin-top:10.0pt;
margin-right:0cm;
margin-bottom:0cm;
margin-left:0cm;
margin-bottom:.0001pt;
page-break-after:avoid;
font-size:13.0pt;
font-family:"Calibri","sans-serif";
color:black;
font-weight:normal;}
h4
{mso-style-priority:9;
mso-style-link:"Heading 4 Char";
margin-top:10.0pt;
margin-right:0cm;
margin-bottom:0cm;
margin-left:0cm;
margin-bottom:.0001pt;
page-break-after:avoid;
font-size:14.0pt;
font-family:"Calibri","sans-serif";
color:black;
font-weight:normal;}
h5
{mso-style-priority:9;
mso-style-link:"Heading 5 Char";
margin-top:10.0pt;
margin-right:0cm;
margin-bottom:0cm;
margin-left:0cm;
margin-bottom:.0001pt;
page-break-after:avoid;
font-size:13.0pt;
font-family:"Calibri","sans-serif";
color:black;
font-weight:normal;}
h6
{mso-style-priority:9;
mso-style-link:"Heading 6 Char";
margin-top:10.0pt;
margin-right:0cm;
margin-bottom:0cm;
margin-left:0cm;
margin-bottom:.0001pt;
page-break-after:avoid;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
color:black;
font-weight:normal;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#996600;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#666666;
text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-priority:99;
mso-style-link:"Balloon Text Char";
margin:0cm;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"Calibri","sans-serif";
color:black;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.Heading1Char
{mso-style-name:"Heading 1 Char";
mso-style-priority:9;
mso-style-link:"Heading 1";
font-family:"Book Antiqua","serif";
color:black;
font-weight:bold;}
span.Heading2Char
{mso-style-name:"Heading 2 Char";
mso-style-priority:9;
mso-style-link:"Heading 2";
font-family:"Book Antiqua","serif";
color:black;}
span.Heading3Char
{mso-style-name:"Heading 3 Char";
mso-style-priority:9;
mso-style-link:"Heading 3";
font-family:"Times New Roman","serif";
color:black;}
span.Heading4Char
{mso-style-name:"Heading 4 Char";
mso-style-priority:9;
mso-style-link:"Heading 4";
font-family:"Times New Roman","serif";
color:black;}
span.Heading5Char
{mso-style-name:"Heading 5 Char";
mso-style-priority:9;
mso-style-link:"Heading 5";
font-family:"Times New Roman","serif";
color:black;}
span.Heading6Char
{mso-style-name:"Heading 6 Char";
mso-style-priority:9;
mso-style-link:"Heading 6";
font-family:"Times New Roman","serif";
color:black;}
span.BalloonTextChar
{mso-style-name:"Balloon Text Char";
mso-style-priority:99;
mso-style-link:"Balloon Text";
font-family:"Tahoma","sans-serif";
color:black;}
..MsoChpDefault
{mso-style-type:export-only;}
[at] page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>

<body bgcolor=3Dwhite background=3D"cid:image001.jpg [at] 01CA81BD.416D13B0" =
lang=3DEN-CA
link=3D"#996600" vlink=3D"#666666">
<img src=3D"cid:image001.jpg [at] 01CA81BD.416D13B0"
v:src=3D"cid:image001.jpg [at] 01CA81BD.416D13B0" v:shapes=3D"_x0000_Mail" =
width=3D0
height=3D0 class=3Dshape style=3D'display:none;width:0;height:0'><!--[if =
gte mso 9]><xml>
<v:background id=3D"_x0000_s1025" o:bwmode=3D"white" =
o:targetscreensize=3D"800,600">
<v:fill src=3D"cid:image001.jpg [at] 01CA81BD.416D13B0" =
o:title=3D"romtextb" type=3D"frame" />
</v:background></xml><![endif]-->

<div class=3DSection1>

<p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif" ;
color:windowtext'>Good Day,<o:p></o:p></span></p>

<p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif" ;
color:windowtext'><o:p> </o:p></span></p>

<p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif" ;
color:windowtext'>         &=
nbsp;      I
need help in in validating a form.<o:p></o:p></span></p>

<p class=3DMsoNormal><span =
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.<o:p></o:p></span></p>

<p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif" ;
color:windowtext'><o:p> </o:p></span></p>

<p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif" ;
color:windowtext'>         &=
nbsp;      The
Form starts with:<o:p></o:p></span></p>

<p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif" ;
color:windowtext'>         &=
nbsp;      <form
name=3D"myForm" action=3D"<?php echo
$_SERVER['PHP_SELF'];?>" method=3D"post" =
onsubmit=3D'return
formValidator()' ><o:p></o:p></span></p>

<p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif" ;
color:windowtext'><o:p> </o:p></span></p>

<p class=3DMsoNormal style=3D'text-indent:36.0pt'><span =
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.<o:p></o:p></span></p>

<p class=3DMsoNormal style=3D'text-indent:36.0pt'><span =
style=3D'font-size:11.0pt;
font-family:"Calibri","sans-serif";color:windowtext'><o:p> </o:p></s=
pan></p>

<p class=3DMsoNormal style=3D'text-indent:36.0pt'><span =
style=3D'font-size:11.0pt;
font-family:"Calibri","sans-serif";color:windowtext'>The PHP only runs =
if the
fields are set by testing using =
‘isset”.<o:p></o:p></span></p>

<p class=3DMsoNormal style=3D'text-indent:36.0pt'><span =
style=3D'font-size:11.0pt;
font-family:"Calibri","sans-serif";color:windowtext'><o:p> </o:p></s=
pan></p>

<p class=3DMsoNormal style=3D'text-indent:36.0pt'><span =
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.<o:p></o:p></span></p>

<p class=3DMsoNormal style=3D'text-indent:36.0pt'><span =
style=3D'font-size:11.0pt;
font-family:"Calibri","sans-serif";color:windowtext'><o:p> </o:p></s=
pan></p>

<p class=3DMsoNormal style=3D'text-indent:36.0pt'><span =
style=3D'font-size:11.0pt;
font-family:"Calibri","sans-serif";color:windowtext'>Thanks every so =
much..<o:p></o:p></span></p>

<p class=3DMsoNormal style=3D'text-indent:36.0pt'><span =
style=3D'font-size:11.0pt;
font-family:"Calibri","sans-serif";color:windowtext'><o:p> </o:p></s=
pan></p>

<p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif" ;
color:windowtext'>....../Ernie<o:p></o:p></span></p>

<p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Ancestory SF";
color:windowtext'><o:p> </o:p></span></p>

<p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Ancestory SF";
color:windowtext'><o:p> </o:p></span></p>

<p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Ancestory SF";
color:windowtext'><o:p> </o:p></span></p>

<p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Ancestory SF";
color:windowtext'><o:p> </o:p></span></p>

<p class=3DMsoNormal><o:p> </o:p></p>

</div>

</body>

</html>

------=_NextPart_001_0002_01CA81BD.7E3A9150--

------=_NextPart_000_0001_01CA81BD.7E39F510--
Ernie Kemp [ Mo, 21 Dezember 2009 03:43 ] [ ID #2026702 ]

Re: Form validation issue

--0016e64c16d4a12d6e047b3642bf
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: quoted-printable

"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 <ernie.kemp [at] sympatico.ca> 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:
>
> <form name=3D"myForm" action=3D"<?php echo
> $_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
>
>
>
>
>
>
>
>
>
>
>

--0016e64c16d4a12d6e047b3642bf--
Midhun Girish [ Mo, 21 Dezember 2009 06:21 ] [ ID #2026703 ]

Re: Form validation issue

--Apple-Mail-1--378752498
Content-Type: text/plain;
charset=utf-8;
format=flowed;
delsp=yes
Content-Transfer-Encoding: quoted-printable

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" <ernie.kemp [at] sympatico.ca>
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:
>
> <form name=3D"myForm" action=3D"<?php echo $_SERVER
> ['PHP_SELF'];?>" method=3D"post" onsubmit=3D'return formValidator()' >
>
>
>
> The =E2=80=9CformValidator()=E2=80=9D 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.
>
>
>
> The PHP only runs if the fields are set by testing using =E2=80=98isset=E2=
=80=9D.
>
>
>
> Without puting on numeric lines of go can you suggest things I must =

> have overlooked. Silly request but there must be something I=E2=80=99m =
overl
> ooking. I have simular code on other programs but this one is cas =

> uing me trouble.
>
>
>
> Thanks every so much..
>
>
>
> ....../Ernie
>
>
>
>
>
>
>
>
>
>

--Apple-Mail-1--378752498--
Phpster [ Mo, 21 Dezember 2009 12:51 ] [ ID #2026704 ]

Re: Form validation issue

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:
> <form name="myForm" action="<?php echo
>$_SERVER['PHP_SELF'];?>" method="post" onsubmit='return
>formValidator()' >
>
>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.
>
>The PHP only runs if the fields are set by testing using 'isset".
>
>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.
>
>Thanks every so much..
>


Ernie:

Client-side javascript can help populate fields and correct any
problems a user might have, but once the form is submitted to the
server, then the data is sent and evaluated server-side, hence
validation.

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.

Cheers,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
TedD [ Mo, 21 Dezember 2009 17:03 ] [ ID #2026707 ]

Re: Form validation issue

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"<?php
echo $_POST[...] ?>" will be sufficient

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
kranthi [ Do, 24 Dezember 2009 10:40 ] [ ID #2027017 ]

Re: Form validation issue

--000e0cd517147f130f047b76d176
Content-Type: text/plain; charset=ISO-8859-1

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:

<input type="text" name="username" value="<?php if
(isset($_POST['username'])) echo $_POST['username'] ?>" id="username" />

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:

<input type... value="<?php echoValue($_POST['username'], $row['username'] )
?>" id="username" />

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 <tedd.sperling [at] gmail.com> 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:
>> <form name="myForm" action="<?php echo
>> $_SERVER['PHP_SELF'];?>" method="post" onsubmit='return formValidator()' >
>>
>> 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.
>>
>> The PHP only runs if the fields are set by testing using 'isset".
>>
>> 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.
>>
>> Thanks every so much..
>>
>>
>
> Ernie:
>
> Client-side javascript can help populate fields and correct any problems a
> user might have, but once the form is submitted to the server, then the data
> is sent and evaluated server-side, hence validation.
>
> 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.
>
> Cheers,
>
> tedd
>
> --
> -------
> http://sperling.com http://ancientstones.com http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--000e0cd517147f130f047b76d176--
Allen McCabe [ Do, 24 Dezember 2009 11:22 ] [ ID #2027018 ]

Re: Form validation issue

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:
>
><input type="text" name="username" value="<?php if
>(isset($_POST['username'])) echo $_POST['username'] ?>"
>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 <input> statements always look like --

<input type="text" name="user_name" value="<?php echo($user_name); ?>" >

-- 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" '

Cheers and Merry Christmas.

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
TedD [ Do, 24 Dezember 2009 16:15 ] [ ID #2027028 ]

Re: Form validation issue

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="<?php
>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.

Cheers and Merry Christmas.

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
TedD [ Do, 24 Dezember 2009 16:21 ] [ ID #2027029 ]
PHP » gmane.comp.php.general » Form validation issue

Vorheriges Thema: idea? add set_trace_handler() to PHP
Nächstes Thema: DailyWTF - Maybe I Needing Later