Skip to main content

Posts

Showing posts from April, 2016

Convert numeric to roman numeric in php and jquery

Convert numeric to roman numeric in php and jquery  PHP Function to convert descimal numeric to roman numeric <?php    function getRomanNumeric($yournumber) { $n = intval($yournumber); $res = ''; $roman_numeric = array( 'M' => 1000, 'CM' => 900, 'D' => 500, 'CD' => 400, 'C' => 100, 'XC' => 90, 'L' => 50, 'XL' => 40, 'X' => 10, 'IX' => 9, 'V' => 5, 'IV' => 4, 'I' => 1); foreach ($roman_numeric as $roman => $numeric) { $matches = intval($n / $numeric); $res .= str_repeat($roman, $matches); $n = $n % $numeric; } return $res; } echo getRomanNumeric(2); ////Ouput of convert numeric to roman numeric - II ?>     jQuery function to convert decimal numeric to roman numeric  function convertToRoman(num) { var roman = ""; var l

Show Instagram feeds to your website with php

How to Show Instagram feeds to your website with php Today we learn how to show instagram feeds and posts to on your website so here is the code for show instagram feeds or posts to on your website .. Requirements Access Token Instagram ID Instagram Account <?php //$userid = "1234567893"; //get this from your instagram account //$accessToken = "798592023.85b53d1.49047a4fcd1b4aebad2e67a56f57f8cc"; //instagram account $url = "https://api.instagram.com/v1/users/{$userid}/media/recent/?access_token={$accessToken}"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 20); $result = curl_exec($ch); curl_close($ch); $result = json_decode($result); ?> <ul> <?php $i=1; foreach ($result->data as $post): ?>     <?php  if($i>5){ break;} ?>     <li><a class="" href="<?php echo $post->images->standard_resolution->ur

use other characters to show password javascript

  How to use other characters to show password javascript         By default whenver we start to type in password field its automatically changed into Asterisk character or sign . but sometimes we need to show password characters into another pattern or format ...like (#####) or a number or a character. So today we learn how to change a textbox field pattern and how to use other character or special symbol to show password. So here is the javascript function and code that will change your input box pattern to show password. In this example we show our password in hash format. <html> <head> <title></title> <script type="text/javascript">    var k=0;    var df; window.onload=function() {    df=document.forms[0]; df[1].onkeyup=function() { df[0].value+=df[1].value.charAt(k);    k++; for(c=0;c<df[1].value.length;c++) {    df[1].value=df[1].value.replace(df[1].value.charAt(c),'#');    }   }  } </script> &

Remove or Add www from url with htaccess

How to remove or add www from website url with htaccess  do you want to remove www from your domain or your website url .so here is the code that will remove www from your domain name . RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] copy this code and paste this code into your .htacces file and if you cannnot find htaccess file in your root directory or create a new one and paste this code into it.this code will redirect every www request to non www weburl of your website. And if you want to add www to your url then copy this code and paste this code into your htaccess file.this code will add www to your url and redirect all requests to www url. How to add www to website url with htaccess   RewriteEngine On RewriteCond %{HTTP_HOST} ^example.com$ RewriteRule (.*) http://www.example.com$1 [R=301]  THANK YOU. Related Posts :

convert html template into cakephp 3 template

Convert html template into cakephp 3 template   to convert a html template into cakephp template please follow these steps * first download cakephp latest version extract it into a folder in your xampp/htdocs/newcake now download your html template * create a new database. navigate to localhost/phpmyadmin and create new database with name like newcake * open cofig/app.php and setup database connection go to line 217  change and change three elements value username , password and database. Example-  'Datasources' => [         'default' => [             'className' => 'Cake\Database\Connection',             'driver' => 'Cake\Database\Driver\Mysql',             'persistent' => false,             'host' => 'localhost',             'username' => 'root', //if you are on localhost then change deault username into into root             'password' => '',    //le

css and js not loading cakephp 3 SOLUTION

CSS and JS not loading cakephp 3 question -  css and js not laoding in cakephp 3 or cakephp 3 css not working Solution Step 1- if your js and css are not loading then open your .htaccess file of root directory (newcake) and if .htaccess file not displaying press ctrl+h to show hidden files and open your .htaccess file and paste this code <IfModule mod_rewrite.c>    RewriteEngine on    RewriteRule    ^$    webroot/    [L]    RewriteRule    (.*) webroot/$1    [L] </IfModule> Step 2- Now open your webroot htaccess file (yourcakephpprojectfolder/webroot) and paste this code into it CakePHP webroot directory - <IfModule mod_rewrite.c>     RewriteEngine On     RewriteCond %{REQUEST_FILENAME} !-f     RewriteRule ^ index.php [L] </IfModule> now refresh your page and see now your css and js are working..Thank You Related Posts -- How to use html template into cakephp 3 Create a cakephp 3 template from html template How to solve css and js not loading pro

Refresh a page after certain delay jquery

Refresh a page after certain delay jquery Solution 1  you can use html meta tag for refresh <meta http-equiv = "refresh" content = "5; URL=http://www.yourdomain.com/yoursite.html" >     Solution 2 if you want to refresh a page after some time with jquery then try this code setTimeout ( function (){ window . location . reload ( 1 ); }, 5000 ); window . setTimeout ( 'location.reload()' , 3000 );       if you want to refresh only one div in every five seconds then try this code   function updateDiv (){ $ ( '# contentDiv' ). html (content ); //content is your ajax data } setInterval ( updateDiv , 5000 ); // That's five seconds     So, every five seconds the contentDiv(id of your div)  content will refresh.and its Better than refreshing the whole page. Related Posts -- How to reload and redirect in jQuery Refresh Only one div with jquery Jquery important short codes and functions

reload and redirect in jQuery

How to reload and redirect in jQuery Reload a page with jquery you can simply reload or refresh a page by this small piece of code. $ ( '#button' ). click ( function () { location . reload (); }); or you can refresh a window using these javascript functions - location = location - location = location . href - location = window . location - location = self . location - location = window . location . href - location = self . location . href - location = location [ 'href' ] - location = window [ 'location' ] - location = window [ 'location' ]. href - location = window [ 'location' ][ 'href' ]   // similar behavior as an HTTP redirect window . location . replace ( "http://thecoderain.blogspot.in" ); // similar behavior as clicking on a link window . location . href = " http://thecoderain.blogspot.in " ; Redirect on another page and pass parameters in url using

jquery not working (SOLUTION)

jQuery not working (SOLUTION) Solution 1 Make sure that first library script loaded on your page. load both scripts in <head> tag before jquery script <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script> Solution 2 if theme jquery is not working then open your theme js file and paste this code on the top of your file var $ = jQuery; this will remove js conflicts from your files . Solution 3 Don’t load two different javascript library versions, only one is ever needed.so chcek in your file that jquery is not load twice. Related Posts how to solve ReferenceError: $ is not defined problem jquery Jquery is undefined problem solution

login and registration with Cakephp 3 tutorial

Create login and registration with Cakephp 3 first you need to install cakephp 3 on your localhost or sever .for installation guide read this post Install Cakephp 3+ without composer on localhost Step 1   open your appController.php (Location :- C://xampp/htdocs/yourproject/src/Controller)   and paste this code into initialize function. public function initialize()     {         $this->set('pageMainHeading', 'Admin');         $this->set('title_for_layout','Admin');         $this->viewBuilder()->layout('default');         $this->loadComponent('Flash');         $this->loadComponent('Auth', [             'loginRedirect' => [                 'controller' => 'AdminUsers',                 'action' => 'index'             ],             'logoutRedirect' => [                 'controller' => 'Pages',                 'action'

Install Cakephp 3+ without composer on localhost

How to Install Cakephp 3 and above on localhost Requirements   you must have xampp installed on your local machine. Install cakephp 3 and above version on localhost in just 5 steps Step 1 -- download the letest version cakephp 3 file  zip from here Step 2 - Unzip this file into              (xampp/htdocs/newcake)  //newcake is your new folder name Step 3 - Create a database into mysql               locate to the localhost/phpmyadmin               and create a new database with name like (ex - newcake) Step 4 - Now go to local disk c:/xampp/htdocs/newcake/config/app.php Step 5 - then go to 228 line and change username password and dbname ex -       'username' => 'root',  //username is always root for localhost             'password' => '',   //password is always blank for localhost             'database' => 'newcake',   Now open your broswer and navigate to localhost/newcake and you see the def

Wordpress user frontend post with media without login

Wordpress user frontend post with media without login create a page userupload.php in your theme to create auser frontend post with media. and paste this code into it <?php /*  Template Name: user-post */ ?><?php get_header(); ?> <?php if(isset($_POST['postsubmit'])) {       $post_title = $_POST['post_title'];   $author_name = $_POST['authorname'];   $post_category = $_POST['cat'];   $post_content_img = $_POST['post_content'];    $uploadOk=1;   if( ! empty( $_FILES['photoContent'] ) ) {   $name = $_FILES["photoContent"]["name"]; $imageFileType = strtolower(end((explode(".", $name)))); # extra () to prevent notice if ($_FILES["photoContent"]["size"] > 500000) {     $msgdata = "<h3 style='color:red'>Sorry, your file is too large.</h3>";     $uploadOk = 0; } if($uploadOk!=0) { if($imageFileType == "jpg" || $imageFileType == "

get the full url in PHP and Wordpress

Get the full url in PHP and WORDPRESS how to get the full url in php and wordpress  these are the outputs of the php tags:- * To get full url or base url in Wordpress $_SERVER [ "DOCUMENT_ROOT" ] === /home/ user / www $_SERVER [ "SERVER_ADDR" ] === 124.16.3.3 $_SERVER [ 'HTTP_HOST' ] === yoursite . com ( or with WWW ) $_SERVER [ "REQUEST_URI" ] === /folder1/ folder2 / yourfile . php ? var =foo #123 __FILE__ === /home/ user / www / folder1 / folder2 / yourfile . php ---> //p.s. ON WINDOWS SERVERS, instead of / is \ basename ( __FILE__ ) === yourfile . php __DIR__ === /home/ user / www / folder1 / folder2 [ same : dirname ( __FILE__ )] $_SERVER [ "QUERY_STRING" ] === var =foo #123 $_SERVER [ "REQUEST_URI" ] === /folder1/ folder2 / yourfile . php ? var =foo #123 parse_url ( $_SERVER [ "REQUEST_URI" ], PHP_URL_PATH ) === /fol