Friday, 23 December 2016

post on facebook via php

<?php
include('src/Facebook/autoload.php');

$fb = new Facebook\Facebook([
  'app_id' => 'app_id',
  'app_secret' => 'app_secret',
  'default_graph_version' => 'v2.8',
  ]);

$accesstoken = "accesstoken";

$linkData = [
  'link' => 'http://www.webbymj.com',
  'message' => 'User provided message',
  ];

try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->post('/me/feed', $linkData, $accesstoken);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}

$graphNode = $response->getGraphNode();

echo 'Posted with id: ' . $graphNode['id'];


?>

Thursday, 22 December 2016

Get mail from gmail with php

<?php
error_reporting('E_ALL');
/* connect to gmail */
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
//$hostname = '{imap.secureserver.net:993/imap/ssl}INBOX';
$username = 'EMIAL@gmail.com';
$password = 'PASSWORD';

/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());

//print_r($inbox);
//exit();
/* grab emails */
//$emails = imap_search($inbox,'ALL');
$emails = imap_search($inbox,'SUBJECT "new requirement"');

/* if emails are returned, cycle through each... */
if($emails) {

/* begin output var */
$output = '';

/* put the newest emails on top */
rsort($emails);

/* for every email... */
foreach($emails as $email_number) {

/* get information specific to this email */
$overview = imap_fetch_overview($inbox,$email_number,0);
$message = imap_fetchbody($inbox,$email_number,2);

/* output the email header information */
$output.= '<div class="toggler '.($overview[0]->seen ? 'read' : 'unread').'">';
$output.= '<span class="subject">'.$overview[0]->subject.'</span> ';
$output.= '<span class="from">'.$overview[0]->from.'</span>';
$output.= '<span class="date">on '.$overview[0]->date.'</span>';
$output.= '</div>';

/* output the email body */
$output.= '<div class="body">'.$message.'</div>';
}

echo $output;
}

/* close the connection */
imap_close($inbox);

?>

Thursday, 1 December 2016

php to excel (download mysql data in ecxel via php)

$output = "";
if(isset($_POST['submit']))
{
$qry = mysql_query("SELECT * FROM ch_countries");
if(mysql_num_rows($qry)>0)
{
$output.= '<table class="table" border="1">
<tr>
<th>ID</th>
<th>Country Code</th>
<th>Country Name</th>
</tr> ';
while($row= mysql_fetch_array($qry))
{
$output .= '
<tr>
<td>'.$row["id"].'</td>
<td>'.$row["country_code"].'</td>
<td>'.$row["country_name"].'</td>
</tr>
';
}
$output .= '</table>';
//important part
header("Conten-Type: application/xls");
header("Content-Disposition: attachment; filename = download.xls");
echo $output;
}

}

Saturday, 19 November 2016

.htaccess code for hide .php / html from file name in browser


RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

Sunday, 9 October 2016

Redirect url / php page without using the header function

if (condition)

 code to execute ; 
 die("<script>location.href = 'http://phpbymj.blogspot.in/'</script>"); 
} else 

 return false; 
}

Wednesday, 5 October 2016

Bootstrap Glyphicons Icon CDN & Example


Below is the sample how to use CDN of Bootstrap Icone

---------------------------------------------------------------------
Bootstrap CDN: 

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    

---------------------------------------------------------------------
All BootstrapIcone find here:
http://www.w3schools.com/icons/bootstrap_icons_glyphicons.asp

---------------------------------------------------------------------
<!DOCTYPE html>
<html>
<head>
<title>Bootsrap Icons</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>


 <span class="glyphicon glyphicon-asterisk"></span> 
 <br>
 <span class="glyphicon glyphicon-plus"></span>
 <br>
 <span class="glyphicon glyphicon-eur"></span>
 <br>
 <span class="glyphicon glyphicon-euro"></span>

</body>
</html>

    

--------------------------------------------------------------------- OUTPUT:

Google Icon for HTML


Below is the sample how to use CDN of Google Icone

---------------------------------------------------------------------
Goggle CDN: 
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">

---------------------------------------------------------------------
All Google Icone find here:
https://design.google.com/icons/


---------------------------------------------------------------------
<!DOCTYPE html>
<html>
<head>
<title>Google Icons</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
</head>
<body>

<p>Some Google icons:</p>
<i class="material-icons">cloud</i>
<i class="material-icons">favorite</i>
<i class="material-icons">attachment</i>
<i class="material-icons">computer</i>
<i class="material-icons">traffic</i>
<br><br>

<p><code>Styled Google icons (size and color):</code></p>
<i class="material-icons" style="font-size:24px;">cloud</i>
<i class="material-icons" style="font-size:36px;">cloud</i>
<i class="material-icons" style="font-size:48px;color:red;">cloud</i>
<i class="material-icons" style="font-size:60px;color:lightblue;">cloud</i>

</body>
</html>

--------------------------------------------------------------------- OUTPUT:


Wednesday, 14 September 2016

Upload image in php with unique name

$file = $_FILES["file"]["name"];
$imageFileType = strtolower(pathinfo($file,PATHINFO_EXTENSION));
$filenamekey = md5(uniqid($file, true));
$filenamekey12 = $filenamekey.".".$imageFileType;
echo $filenamekey12;
move_uploaded_file($_FILES['file']['tmp_name'],'image/'.$filenamekey12);

Wednesday, 20 July 2016

Dynamic dropdown from database via Jquery

HTML File

 <tr>
            <th  scope="row">Select Brand:</th>
            <td>
            <select class="form-control" onChange="GetModel($brand)" id="brand" name="brand">
            <option value="">Select </option>
            <?php GetBrand(); ?>    
            </select>
            </td>
          </tr>
          <tr>
            <th scope="row">Phone Model</th>
            <td>
<div class="Xform-group">
<!-- <label class="control-label col-md-3">2</label>-->
<div class="Xcol-md-9">
<!-- <textarea class="wysihtml5 form-control" rows="6"  name="job_description" placeholder="Job Description" required></textarea>  -->
 <select class="form-control input-large" id="model" name="model">
      
          </select>
        </div>
</div>
</td>
          </tr>



Jquery for this 


<script>
$(document).ready(function(e) {
$("#brand").change(function(){
// alert('this is working');
$("#model").load("dynamic_data.php?brand=" + $("#brand").val());
});
});

</script>


dynamic_data.php


<?php 
include('db_config.php');
$brand = mysqli_real_escape_string($db,$_GET['brand']);
echo $brand;
$qry = "SELECT * FROM mobile_model WHERE brand = '$brand';";
$run = mysqli_query($db,$qry);

while($res = mysqli_fetch_array($run))
{
?>
    <option value="<?php echo $res['model_id'];  ?>">
    <?php
echo $res['model_name'];
?>
</option>

    <?php
}

?>

Sunday, 10 July 2016

Saturday, 9 July 2016

Solved : how to Increase size of wordpress | Plugin not opening correctly due to limit exceeded |

Change the limit Size in this file:

http://Localhost/domainName/wp-includes/default-constants.php


Before:

// set memory limits
if ( !defined('WP_MEMORY_LIMIT') ) {
if ( is_multisite() ) {
define('WP_MEMORY_LIMIT', '64M');
} else {
define('WP_MEMORY_LIMIT', '40M');
}
}

Change this to this:

// set memory limits
if ( !defined('WP_MEMORY_LIMIT') ) {
if ( is_multisite() ) {
define('WP_MEMORY_LIMIT', '128M');
} else {
define('WP_MEMORY_LIMIT', '40M');
}
}


And Save it .
and you have Done it Enjoy!.

Solved: How to delay a div with time ?


//Include Jquery Library
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>


<script>
$(document).ready(function() {
    $('#DivId').delay(2000).fadeIn(1000);
});

</script>

Note* : Make sure you did
style="display:none;" of that Div 

Tuesday, 5 July 2016

Solved: Wordpress Image URL not working

UPDATE wp_posts SET post_content = REPLACE(post_content, 'http://localhost/wordpress', 'http://itplsoft.com/wordpress/');

Saturday, 2 July 2016

Bootstrap code embedded to wordpress

function enqueue_my_scripts() {
wp_enqueue_script( 'jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js', array('jquery'), '1.9.1', true); // we need the jquery library for bootsrap js to function
wp_enqueue_script( 'bootstrap-js', '//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js', array('jquery'), true); // all the bootstrap javascript goodness
}
add_action('wp_enqueue_scripts', 'enqueue_my_scripts');

Font Awesome embed code

<script src="https://use.fontawesome.com/d5837faf63.js"></script>


1Copy this code & place in your HTML's <head>
2Use any of Font Awesome 605+ icons in your project's UI



Thursday, 19 May 2016

Wordpress default table. How many table wordpress create on installation?

Interview quetion on WordPress.

How many table created by wordpress on installation ???

How many table in wordpress??

The answer is 12.

WordPress create 12 table by default which you can find out here.

1. wp_commentmeta
2. wp_comments
3. wp_links
4. wp_options
5. wp_postmeta
6. wp_posts
7. wp_term_relationships
8. wp_term_taxonomy
9. wp_termmeta
10. wp_terms
11. wp_usermeta
12. wp_users

Below is the fresh photo your wordpress database.







Friday, 6 May 2016

Complete Form Validate in JavaScript

You Just need to use you input type field "id" same in the below code and rest is fine.

Form in browser.


Java Script Code:
JavaScript code should be use within the <Head>tab or <Body> tab.

<script language="javascript" type="text/javascript">
function myTrim(x) {
    return x.replace(/^\s+|\s+$/gm,'');
}

function validateForm()
{
    var full_name = document.getElementById('full_name').value;
var address_line_1 = document.getElementById('address_line_1').value;
var city = document.getElementById('city').value;
var state = document.getElementById('state').value;
var pincode = document.getElementById('pincode').value;
var country = document.getElementById('country').value;
var mobile = document.getElementById('mobile').value;
full_name = myTrim(full_name);
address_line_1 = myTrim(address_line_1);
city = myTrim(city);
state = myTrim(state);
pincode = myTrim(pincode);
country = myTrim(country);
mobile = myTrim(mobile);

if(full_name == ""){
alert("Name must be filled out");
        return false;
    }
if(!full_name.match(/^[A-Za-z ]+$/)){
alert("Name must be alphabetic Only ");
        return false;
    }
if(address_line_1 == ""){
alert("Address 1 must be filled out");
        return false;
    }
if(city == ""){
alert("City must be filled out");
        return false;
}
if(!city.match(/^[A-Za-z]+$/)){
alert("City must be in alphabetic ");
        return false;
    }

if(state == ""){
alert("State must be filled out");
        return false;
    }
if(pincode == ""){
alert("Pin Code must be filled out");
        return false;
    }

if(pincode.length < 6 || pincode.length > 6 ){
alert("Pincode Code must 6x digit.");
        return false;
    }
if(!pincode.match(/^[0-9]*$/)){
alert("Pincode must be numeric Only ");
        return false;
    }

if(country == ""){
alert("Country must be filled out");
        return false;
    }
if(mobile == ""){
alert("Mobile must be filled out.");
        return false;
    }
if(mobile.length < 10 || mobile.length > 10 ){
alert("Mobile No. must ten digit.");
        return false;
    }


var mobile_start = mobile.substring(0,1);
if(mobile_start.match(9) || mobile_start.match(8) || mobile_start.match(7))
{ }
else
{
alert("Insert a valid mobile number.");

return false;


}

if(!mobile.match(/^[0-9]*$/)){
alert("Mobile must be numeric Only ");
        return false;
    }

// alert("Mobile: "mobile_start);
/* if(mobile_start !==9 || mobile_start !== 7){
alert("Please Enter Valid Mobile No.");
        return false;
    }
*/

/* if(mobile.length < 10 || mobile.length > 10 ){
alert("Mobile No. must ten digit.");
        return false;
    }



if(mobile.match("^[789]\d{9}$"))
        {
      return true;
        }
      else
        {
        alert("message");
        return false;
        }
*/
}

</script>



HTML CODE:

<form name="delivery_address" method="post" action="address.php" enctype="multipart/form-data"  >

<div>Full name: <div><input type="text" name="full_name" value="<?php echo $full_name; ?>" /><span style="color:red;">*</span></div></div>
<div>Address Line 1:  <div><input type="text" name="address_line_1" value="<?php echo $address_line_1; ?>"  /><span style="color:red;">*</span></div></div>
<div>Address Line 2:  <div><input type="text" name="address_line_2"  value="<?php echo $address_line_2; ?>" /></div></div>
<div>Town/City:  <div><input type="text" name="city"  value="<?php echo $city; ?>" required="required" /><span style="color:red;">*</span></div></div>

<div>State:  <div><select name="state" id="state"  >
<option value="ANDAMAN AND NICOBAR ISLANDS">ANDAMAN AND NICOBAR ISLANDS</option>
<option value="ANDHRA PRADESH">ANDHRA PRADESH</option>
<option value="ARUNACHAL PRADESH">ARUNACHAL PRADESH</option>
<option value="ASSAM">ASSAM</option>
<option value="BIHAR">BIHAR</option>
<option value="CHANDIGARH">CHANDIGARH</option>
<option value="CHHATTISGARH">CHHATTISGARH</option>
<option value="DADRA AND NAGAR HAVELI">DADRA AND NAGAR HAVELI</option>
<option value="DAMAN AND DIU">DAMAN AND DIU</option>
<option value="DELHI">DELHI</option>
<option value="GOA">GOA</option>
<option value="GUJARAT">GUJARAT</option>
<option value="HARYANA">HARYANA</option>
<option value="HIMACHAL PRADESH">HIMACHAL PRADESH</option>
<option value="JAMMU AND KASHMIR">JAMMU AND KASHMIR</option>
<option value="JHARKHAND">JHARKHAND</option>
<option value="KARNATAKA">KARNATAKA</option>
<option value="KERALA">KERALA</option>
<option value="LAKSHADWEEP">LAKSHADWEEP</option>
<option value="MADHYA PRADESH">MADHYA PRADESH</option>
<option value="MAHARASHTRA">MAHARASHTRA</option>
<option value="MANIPUR">MANIPUR</option>
<option value="MEGHALAYA">MEGHALAYA</option>
<option value="MIZORAM">MIZORAM</option>
<option value="NAGALAND">NAGALAND</option>
<option value="ORISSA">ORISSA</option>
<option value="PONDICHERRY">PONDICHERRY</option>
<option value="PUNJAB">PUNJAB</option>
<option value="RAJASTHAN">RAJASTHAN</option>
<option value="SIKKIM">SIKKIM</option>
<option value="TAMIL NADU">TAMIL NADU</option>
<option value="TELANGANA">TELANGANA</option>
<option value="TRIPURA">TRIPURA</option>
<option value="UTTAR PRADESH">UTTAR PRADESH</option>
<option value="UTTARAKHAND">UTTARAKHAND</option>
<option value="WEST BENGAL">WEST BENGAL</option>

</select><span style="color:red;">*</span></div></div>

<div>Pincode:  <div><input type="text" name="pincode" value="<?php echo $pincode; ?>" required="required" /><span style="color:red;">*</span></div></div>
<div>Country:  <div><select name="country" id="country">
<option value="India">India</option>
</select> <span style="color:red;">*</span></div></div>
<div>Mobile number:  <div><input type="text" name="mobile" value="<?php echo $mobile; ?>" maxlength="10"  required="required"/><span style="color:red;">*</span></div></div>
<div>Landmark: <div><input type="text" name="landmark" value="<?php echo $landmark; ?>" /></div></div>
<div>Address Type: <div>
<select name="address_type" value="<?php echo $address_type; ?>" >
<option value="Home">Home</option>
<option value="Company">Company</option>

</select><span style="color:red;">*</span></div></div>
<br />
<div><div><input type="submit" name="submit" value="Deliver to this address"  onclick="return validateForm()"   /></div></div>

</form>

Drop Down list code for all state in India. select code for state in india(HTML).

Just Copy and paste where you want to use it.

<select name="state" id="state"  >

<option value="ANDAMAN AND NICOBAR ISLANDS">ANDAMAN AND NICOBAR ISLANDS</option>
<option value="ANDHRA PRADESH">ANDHRA PRADESH</option>
<option value="ARUNACHAL PRADESH">ARUNACHAL PRADESH</option>
<option value="ASSAM">ASSAM</option>
<option value="BIHAR">BIHAR</option>
<option value="CHANDIGARH">CHANDIGARH</option>
<option value="CHHATTISGARH">CHHATTISGARH</option>
<option value="DADRA AND NAGAR HAVELI">DADRA AND NAGAR HAVELI</option>
<option value="DAMAN AND DIU">DAMAN AND DIU</option>
<option value="DELHI">DELHI</option>
<option value="GOA">GOA</option>
<option value="GUJARAT">GUJARAT</option>
<option value="HARYANA">HARYANA</option>
<option value="HIMACHAL PRADESH">HIMACHAL PRADESH</option>
<option value="JAMMU AND KASHMIR">JAMMU AND KASHMIR</option>
<option value="JHARKHAND">JHARKHAND</option>
<option value="KARNATAKA">KARNATAKA</option>
<option value="KERALA">KERALA</option>
<option value="LAKSHADWEEP">LAKSHADWEEP</option>
<option value="MADHYA PRADESH">MADHYA PRADESH</option>
<option value="MAHARASHTRA">MAHARASHTRA</option>
<option value="MANIPUR">MANIPUR</option>
<option value="MEGHALAYA">MEGHALAYA</option>
<option value="MIZORAM">MIZORAM</option>
<option value="NAGALAND">NAGALAND</option>
<option value="ORISSA">ORISSA</option>
<option value="PONDICHERRY">PONDICHERRY</option>
<option value="PUNJAB">PUNJAB</option>
<option value="RAJASTHAN">RAJASTHAN</option>
<option value="SIKKIM">SIKKIM</option>
<option value="TAMIL NADU">TAMIL NADU</option>
<option value="TELANGANA">TELANGANA</option>
<option value="TRIPURA">TRIPURA</option>
<option value="UTTAR PRADESH">UTTAR PRADESH</option>
<option value="UTTARAKHAND">UTTARAKHAND</option>
<option value="WEST BENGAL">WEST BENGAL</option>

</select>