Skip to content

Instantly share code, notes, and snippets.

View Shakil-Shahadat's full-sized avatar
🏠
Working from home

Shakil Shahadat Shakil-Shahadat

🏠
Working from home
View GitHub Profile
@Shakil-Shahadat
Shakil-Shahadat / common.css
Last active November 23, 2020 22:49
Some Common CSS Styles I Regularly Use
body
{
font-family: 'Segoe UI', Verdana, Arial, Helvetica, sans-serif;
background-color: whitesmoke;
line-height: 26px;
}
.container
{
background: white;
border: 1px solid silver;
@Shakil-Shahadat
Shakil-Shahadat / Ajax GET Request.js
Last active December 25, 2020 11:49
IE10+ [ Obsolete, use fetch instead ]
let http = new XMLHttpRequest();
http.open( 'GET', 'get.php' );
http.send();
http.onreadystatechange = function()
{
if ( http.readyState == 4 && http.status == 200 )
{
console.log( http.responseText );
}
}
@Shakil-Shahadat
Shakil-Shahadat / Ajax POST request.js
Last active December 25, 2020 11:59
Ajax POST request with data [ Obsolete, use fetch instead ]
let data1 = 'Hello World!';
let data2 = 'Hello Universe!';
let http = new XMLHttpRequest();
http.open( 'POST', 'post.php' );
http.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
http.send( 'data1=' + data1 + '&data2=' + data2 );
http.onreadystatechange = function()
{
if ( http.readyState == 4 && http.status == 200 )
{
@Shakil-Shahadat
Shakil-Shahadat / Anchor.js
Last active December 18, 2021 01:50
Add target="_blank" attribute to all anchor tags
// Add target="_blank" to all anchor tags, v 1.05
for ( x of document.querySelectorAll( 'a' ) ) x.setAttribute( 'target', '_blank' );
@Shakil-Shahadat
Shakil-Shahadat / index.php
Created September 4, 2017 01:26
Form Input Test: Variable Value in Radio Input, Proof of Concept
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Form Input Test: Variable Value in Radio Input, Proof of Concept (Success)</title>
</head>
<body>
<?php
// echo "<pre>"; print_r( $_POST ); echo "</pre>";
@Shakil-Shahadat
Shakil-Shahadat / create_db.php
Last active December 18, 2021 01:46
Create Database
<?php
require_once 'db_info.inc';
$db = new mysqli( $servername, $username, $password );
if ( $db->connect_error ) die( 'Connection Error: ' . $db->connect_error );
$result = $db->query( "CREATE DATABASE IF NOT EXISTS $database" );
if ( $db->error ) die( 'Query Error: ' . $db->error );
else echo 'Database creation successful.';
@Shakil-Shahadat
Shakil-Shahadat / escapeArray.php
Last active December 18, 2021 01:43
Escape an Array in Easiest Way
<?php
// For MySQL
// Escape $_GET elements
foreach ( $_GET as $key => $value )
{
$_GET[ $key ] = $db->escape_string( $_GET[ $key ] );
}
// Escape $_POST elements
@Shakil-Shahadat
Shakil-Shahadat / .htaccess
Created March 22, 2019 17:51
Redirect to ssl version of a site
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
@Shakil-Shahadat
Shakil-Shahadat / mail.php
Last active December 18, 2021 01:42
Send Email Using PHP
<?php
$to = 'test@example.com';
$subject = 'Test mail';
$message = 'Hello! This is a simple email message.';
$from = 'someone@example.com';
$headers = 'From: ' . $from;
mail( $to, $subject, $message, $headers );
echo 'Mail Sent.';
@Shakil-Shahadat
Shakil-Shahadat / storageCheck.js
Last active September 24, 2019 07:25
Check for localStorage/sessionStorage
if ( typeof( Storage ) !== 'undefined' )
{
console.log( 'Storage Exists!' );
}
else
{
console.log( 'Storage doesn\'t Exists!' );
}