Controlling Forms

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Pintonite
Forum Newbie
Posts: 17
Joined: Mon May 20, 2002 5:11 pm
Contact:

Controlling Forms

Post by Pintonite »

I know I have seen it somewhere on this site but I need the code to be able to control the kind of information being passed in a form.

ie.

enter your birthdate: jeff

error message: that is not a birthdate, goofball.


thanks for the help
User avatar
protokol
Forum Contributor
Posts: 353
Joined: Fri Jun 21, 2002 7:00 pm
Location: Cleveland, OH
Contact:

Post by protokol »

this is standard form validation .. usually this is processed via a POST request sent by the browser .. there are many functions which can be useful, but the one you will probably want to learn is preg_match()

http://www.php.net/manual/en/function.preg-match.php
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

For specifically checking dates there is the checkdate() function.

Mac
will
Forum Contributor
Posts: 120
Joined: Fri Jun 21, 2002 9:38 am
Location: Memphis, TN

Post by will »

twigletmac wrote:For specifically checking dates there is the checkdate() function.

Mac

just do keep in mind that checkdate() is not y33k compliant :)
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

"in the year 2525, if man is still alive, if woman can survive....." ;)
*sorry, spam-only*
Pintonite
Forum Newbie
Posts: 17
Joined: Mon May 20, 2002 5:11 pm
Contact:

Post by Pintonite »

Damn, I might not have explained myself good enough. I need to figure out how to make it so a person can only type in a valid number where numbers are supposed to go and/or a valid letter where letters are supposed to go in a form. perhaps I don't really understand
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Well then, check out the is_something() functions. To start you off here's one that will check that a given value is numeric:
http://www.php.net/manual/en/function.is-numeric.php

Also as Protokol said the preg_match() function will be very useful too.

Mac
Pintonite
Forum Newbie
Posts: 17
Joined: Mon May 20, 2002 5:11 pm
Contact:

Post by Pintonite »

Thanks for the help.
I do understand now.
Post Reply