Skip to content

Instantly share code, notes, and snippets.

View kaqfa's full-sized avatar
😁

Fahri Firdausillah kaqfa

😁
View GitHub Profile
<?php
class Paginasi{
function __construct($pdo_connect, $sql, $num_per_page, $url_pattern){
$this->db = $pdo_connect;
$this->sql = $sql;
$this->npp = $num_per_page;
$this->url = 'http://'.$_SERVER['HTTP_HOST'].$url_pattern;
$this->cpage = (isset($_GET['p']) ? $_GET['p'] : 0);
'''
Langkahnya adalah:
- create db for new wordpress
- create db user for new db
- download latest WP
- untar WP
- run wordpress in browser
'''
@kaqfa
kaqfa / pythonic_way.ipnb
Created August 20, 2017 16:12
Notebook for PythonIDSemarang
{
"cells": [
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Admin Display</title>
</head>
<body>
<h1>whatever you display in admin page</h1>
<h2><?php echo "current user:".$user; ?></h2>
<a href="process.php?action=logout">Logout</a>
<?php
session_start();
// $user = $_SESSION['login'];
$user = $_COOKIE['login'];
if($user){
require "../php/admin_input_mhs.php";
} else {
header("location:login.php");
}
<?php
$db_name = 'test';
$db_host = 'localhost';
$db_username = 'root';
$db_passwd = '';
try {
$db = new PDO("mysql:dbname=".$db_name.";host=".$db_host,
$db_username, $db_passwd);
<?php
session_start();
require "../pdo/connection.php";
function loginCheck(){
global $db;
$prep = $db->prepare("select * from users where username=?");
$prep->execute(array($_POST['username']));
$res = $prep->fetch();
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Login Page</title>
</head>
<body style="margin-left: auto; margin-right: auto; padding-top: 20px;">
<form action="process.php" method="post">
<table>
<tr>
@kaqfa
kaqfa / user_table.sql
Last active December 19, 2016 10:32
Kumpulan kode manajemen login dengan PDO (PHP Data Object)
CREATE TABLE `users` (
`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
`username` varchar(50) NOT NULL,
`password` varchar(50) NOT NULL,
`full_name` varchar(100) NOT NULL,
`email` varchar(100) NOT NULL
);
server {
listen 80;
server_name yourdomain.net;
location /static {
alias /home/youruser/webapp/staticfiles;
}
location / {
sub_filter_types text/plain application/json;