beginning_php thread: form validation by type?
Message #1 by "Rob Blake" <rob_blake@h...> on Thu, 18 Apr 2002 15:46:00|
just wondering if there is any way that you can validate forms by the type
of data entered. I am wanting to check the form so that if a user enters a
string where there should be an int, the script picks up on it.
Message #2 by "Gellings, C.O." <gellingsco@p...> on Thu, 18 Apr 2002 17:05:39 +0200|
Yes, but you need to query all the fields or make two arrays, containing the
field names, one for string, one for integer and go through the motions in a
the next page which is defined by the submitbutton.
Your form can look like this:
<td>item1<td><input type="text" value="??" name="xx"></td>
<td> item2<td> ...
<input type="hidden" name="submitted" value="yes">
<input type="submit" value="Save" name="submit">
<input type="reset" value="Reset" name="reset">
<input type="button" value="Cancel" >
at the top of the php file you refer to in the form's action property you
if($submitted == "yes")
Where bCheckItems() is the function in which you verify string and integer
> -----Original Message-----
> From: Rob Blake [mailto:rob_blake@h...]
> Sent: 18 April 2002 15:46
> To: beginning php
> Subject: [beginning_php] form validation by type?
> just wondering if there is any way that you can validate forms by
> the type
> of data entered. I am wanting to check the form so that if a user
> enters a
> string where there should be an int, the script picks up on it.
> Many thanks
> Rob Blake