Sanitizing PHP/SQL $_POST, $_GET, etc…?

前端 未结 3 1528
长情又很酷
长情又很酷 2021-01-15 05:10

Ok, this subject is a hotbed I understand that. I also understand that this situation is dependent on what you are using as code. I have three situations that need to be r

3条回答
  •  终归单人心
    2021-01-15 05:48

    Regarding the sanitization of dates, PHP has some built-in functions that can be helpful. The strtotime() function will convert just about any imaginable date/time format into a Unix timestamp, which can then be passed to the date() function to convert it to whatever formatting you like.

    For example:

    $date_sql = date( "Y-m-d", strtotime( $_POST["date"] ) );

提交回复
热议问题