Validating date in php

“30/2/2008”, “31/02/2008” – leap year in February has 29 days only 5.

Such code can now do no harm and is safe to be displayed on a page or inside an e-mail. if quotes are escaped with a slash \ let's remove that.

“31/6/2010”, “31/06/2010” -June has 30 days only 9.

“31/4/20100”, “31/04/2010” – April has 30 days only 8.

You may opt for sending form data to a different file.

Validation for non-empty, alphabets and whitespace only The following code is added within the form So, if you try to understand how to write code for it step by step, step 1 is to declare the mail address to whom you want to send mail, step 2 is to write subject of the mail, step three is to collect data from POST so that you can write them to the body of mail, step 4 is to declare the mail id from which the mail is coming and finally sent mail with PHP mail() function.

In this tutorial, we will see how to use PHP to validate the data collected from a form.

“31/9/2010”, “31/09/2010” – September has 30 days only 10.attributes, which give a suggestion for an initial size (based on the number of characters that should be displayed vertically and horizontally).This is a little unusual, since it forces you to specify display related information in the HTML, but you can always override them using the This allows the user to choose a file that will be uploaded to the server.[1-9] # 01-09 or 1-9 | # .1[012] # 10,11,12 ) # end of group #2 / # follow by a "/" ( # start of group #3 (19|20)\d\d # 19[0-9][0-9] or 20[0-9][0-9] ) # end of group #3 The above regular expression is used to validate the date format in “dd/mm/yyyy”, you can easy customize to suit your need. However, it’s a bit hard to validate the leap year , 30 or 31 days of a month, we may need basic logic as below.

Leave a Reply