Skip to content

Instantly share code, notes, and snippets.

View MakkiAbid's full-sized avatar

Muhammad MakkiAbid

View GitHub Profile
@MakkiAbid
MakkiAbid / Class that performs basic CRUD operations
Created July 13, 2021 05:42
PDO Based CRUD operations in PHP
<?php
class DataBase
{
protected $connection;
public function __construct($host, $db, $user, $pass, $charset = 'utf8mb4', $options = []){
$options = array_merge([
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
<title>JS Bin</title>
</head>
<body>
<p id="data"></p>
@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>';
}