How to collect Date of birth from php form and insert into mysql?

梦想与她 提交于 2020-02-04 14:28:58

问题


I am new to programming, have done a few things but i have no idea how to collect dob information. How do i collect it from a form and how do i insert it? Do i use three fields: month/day/year and then in the db also have three columns?

Is there a tutorial i can be pointed to?

Thanks


回答1:


Depending on what you're going to do with the data (if it's not going to be too complex), you could simply reformat the submitted form:

$bday = date('Y-m-d',strtotime($_POST['userSubmittedBDay']));

and insert that into the database as a string. The above example would give you the format 2011-01-26




回答2:


Sorry if this is a cheeky response, but with a little Google-ing this answer can be found rather easily.

  1. Create a form
  2. Collect data from that form
  3. Sanitize that input
  4. Insert into database


来源:https://stackoverflow.com/questions/4812194/how-to-collect-date-of-birth-from-php-form-and-insert-into-mysql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!