Wednesday, 30 September 2020

Browser API PHP get from php script

 <?php


$username = $_GET['txtUsername'];

//url.php?txtUsername=nama%20saya

echo "username is " . $username;

    $email = $_GET['txtEmail'];

    $password = $_GET['txtPassword'];

    $ConfPassword = $_GET['txtConfirmPassword'];

?>

Tuesday, 29 September 2020

Redirect Error Page HTTP to HTTPS

1. Open Cpanel 

2. Go to Error Page

3. Open any of the error and put this code

4. change the url


<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<script>location.href = 'https://korodklothing.com';</script>

</head>

<body></body>

</html>

PHP MYSQL TO JSON

https://www.opentechguides.com/how-to/article/php/100/mysql-to-json.html

<?php

// Initialize variable for database credentials
$dbhost = 'hostname';
$dbuser = 'username';
$dbpass = 'password';
$dbname = 'sakila';

//Create database connection
  $dblink = new mysqli($dbhost, $dbuser, $dbpass, $dbname);

//Check connection was successful
  if ($dblink->connect_errno) {
     printf("Failed to connect to database");
     exit();
  }

//Fetch 3 rows from actor table
  $result = $dblink->query("SELECT * FROM actor LIMIT 3");

//Initialize array variable
  $dbdata = array();

//Fetch into associative array
  while ( $row = $result->fetch_assoc())  {
	$dbdata[]=$row;
  }

//Print array in JSON format
 echo json_encode($dbdata);
 
?>

Result:


[
	{
	"actor_id":"1",
	"first_name":"PENELOPE",
	"last_name":"GUINESS",
	"last_update":"2006-02-15 04:34:33"
	},
	{	
	"actor_id":"2",
	"first_name":"NICK",
	"last_name":"WAHLBERG",
	"last_update":"2006-02-15 04:34:33"
	},
	{
	"actor_id":"3",
	"first_name":"ED",
	"last_name":"CHASE",
	"last_update":"2006-02-15 04:34:33"
	}
]

As you can see, the result is a valid JSON. You may use this in combination with Jquery/AJAX to pass database data to a web application that expects data in JSON.

Friday, 25 September 2020

Add multiple Functions.php wordpress

require_once( get_stylesheet_directory(). '/woocommerce.php' ); 

require_once( get_stylesheet_directory(). '/widget.php' ); 

Thursday, 24 September 2020

HOW TO BACKUP AND RESTORE WHATSAPP DB

  1.   Buka ko punya whatsapp folder
  2. Cari file .db di backup
  3. ganti dengan .db sedia ada, rename ikut sama

Thursday, 10 September 2020

UNBREAK DIVI CSS COLUMN

 Below is the code

@media only screen and (max-width: 980px) {
 
.two-columns .et_pb_column {
width: 50%!important;
}
 
.three-columns .et_pb_column {
width: 33.33%!important;
}
 
.four-columns .et_pb_column {
width: 25%!important;
}
}
Take the first class example three-columns, copy without dot. And paste in divi column id/class

Sunday, 6 September 2020

Wordpress Dashboard Widget. Multiple

 $helloMuhaza = 'Hello, Muhaza Nak Letak Something Sini'.' <a href="/">a</a>';


add_action( 'wp_dashboard_setup', 'muhaza_widget_001' );

function muhaza_widget_001() {

    wp_add_dashboard_widget(

        'muhaza_001_dashboard_widget',/*nama widget*/

        'Widget Muhaza 001',/*Screen Option Button*/

        'muhaza_widget_001_display'/*function*/

    );

}


function muhaza_widget_001_display() {

    echo $GLOBALS['helloMuhaza'];

}


//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

add_action( 'wp_dashboard_setup', 'muhaza_widget_002' );

function muhaza_widget_002() {

    wp_add_dashboard_widget(

        'muhaza_002_dashboard_widget',/*nama widget*/

        'Widget Muhaza 002',/*Screen Option Button*/

        'muhaza_widget_002_display'/*function dalam*/

    );

}


function muhaza_widget_002_display() {

    echo $GLOBALS['helloMuhaza'];

}


Full width IFrame

 

iframe {
position: fixed;
background: #000;
border: none;
top: 0; right: 0;
bottom: 0; left: 0;
width: 100%;
height: 100%;
}

Saturday, 5 September 2020

If current User (Role) Execute Code

<?php if( current_user_can('editor') || current_user_can('administrator') ) { 

    // Stuff here for administrators or editors

} ?>

Wednesday, 2 September 2020

WP Function Add_Action Redirect If !Not Logged In

Template Redirect → function → member only → If open page → Not Logged In → redirect to home url


 <?php

add_action('template_redirect','members_only');

function members_only(){

if( is_page('page-slug') && ! is_user_logged_in()){

wp_redirect( home_url());

die();

}

?>

email mailto: pretext

 <a href="mailto:designoutsourced.com+info@gmail.com?subject=Maklumat%20lanjut%20pakej&body=Hai,%20saya%20berminat%20tahu%20lebi...