Skip to content

Instantly share code, notes, and snippets.

View alyjee's full-sized avatar
💭
code

Tahir Raza alyjee

💭
code
View GitHub Profile
@MakkiAbid
MakkiAbid / PK CNIC Regex
Last active March 20, 2021 13:28
Pakistan's CNIC Regex PHP
// cnic check empty or valid
if (isset($_POST['cnic']) && !empty($_POST['cnic'])) {
if (preg_match('/^([0-9]{5})[\-]([0-9]{7})[\-]([0-9]{1})+/', $_POST['cnic'])) {
$cnic = clearInput($_POST['cnic']);
} else {
$cnic_error = '<p class="text-danger">Only numerics are allowed.</p>';
}
} else {
$cnic_error = '<p class="text-danger">Field is not to be empty.</p>';
}