Jump to content

Recommended Posts

hello

 

i wanna made a form that has the year

but i don`t wanna make it with list

i want them to put the year instead like : 07 ,, 08

how do i do it in php to give error if they put something else

 

something like this

 

 

$ar = array("07","08","09","10");

 

foreach ($ar as $year)

etc etc

 

i think something like that

thanks in advance

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/69737-some-help/
Share on other sites

you want them to enter year into a box or select it from a pulldown?

(pull down is better)

If they type in the year, you have to verify it's a valid year OR verify that year exists in the database as written.

 

Pulldown created dynamically

(select distinct year from table order by year asc...)

seems the best to me, not knowing what you are looking for...

Link to comment
https://forums.phpfreaks.com/topic/69737-some-help/#findComment-350406
Share on other sites

Well, I would allow them to enter from 1 to 4 digits (regex to verify they are numbers only)

then maybe pad left with 0's if the string length = 1

then set

$variable=subst($whatever,-2,2)

 

and that would always give you a number with leading 0 if they only put a "7" which lazy people like me do

Link to comment
https://forums.phpfreaks.com/topic/69737-some-help/#findComment-350432
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.