Tuesday 13 September 2016

how to share any post on facebook in php

<?php
$data = "pppppppppppppppppppppppppppp";

?>
<html>
     

<head>
    <title>Facebook Share Button - External Website</title>
   
<style type="text/css">

body { 
background:#f5f5f5;
font: 14px/150% 'century gothic',helvetica,arial;
}

#container {
margin:5px auto;
padding:25px;
width:400px;
border:1px solid #999;
border-radius:8px; -moz-border-radius:8px; -webkit-border-radius:8px;
background:#fff;
}
</style>


</head>

<body>

<div id="container">

<p>Manjeet kashyap</p>

<div id="fb-root"></div>


<script>
 window.fbAsyncInit = function() {
FB.init({

 appId  : '964579503687504',
 status : true, // check login status
 cookie : true, // enable cookies to allow the server to access the session
 xfbml  : true  // parse XFBML
});
 };

 (function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
 }());
</script>


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript"></script>

<img id = "share_button" src = "http://app.tabpress.com/fbui_share/share_button.png">

<script type="text/javascript">
$(document).ready(function(){
$('#share_button').click(function(e){

e.preventDefault();
var m = "<?php echo $data; ?>";
FB.ui(
{

method: 'feed',
name: 'HyperArts Blog',
link: 'http://hyperarts.com/blog',
picture: 'http://www.hyperarts.com/_img/TabPress-LOGO-Home.png',
caption: 'I love HyperArts tutorials',
description: m,
message: ''
});
});
});
</script>


</div>

</body>
</html>

Friday 9 September 2016

how to check email valid on server in php.

$email = "john@gmail.com";

if (!filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
  echo("$email is a valid email address");
} else {
  echo("$email is not a valid email address");
}

Tuesday 6 September 2016

how to call page content in template file in wordpress.

<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'page' ); ?>
<?php comments_template( '', true ); ?>
<?php endwhile; // end of the loop. ?>

Sunday 21 August 2016

how to get address from latitude and longitude.

$geocode=file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?latlng=30.6978446,76.717779&sensor=false');

$output= json_decode($geocode);
//print_r($output);
echo $output->results[0]->formatted_address;

how to get latitude and longitude from Address .

$address = 'sector 70 mohali';

$geo = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?address='.urlencode($address).'&sensor=false');

$geo = json_decode($geo, true);

if ($geo['status'] == 'OK') {
 $latitude = $geo['results'][0]['geometry']['location']['lat'];
 $longitude = $geo['results'][0]['geometry']['location']['lng'];
}

Tuesday 9 August 2016

how to create REST API in php

Simple three Step create Rest API 

STEP->1 create config.php

STEP-> 2create api.php

STEP-> 3create class.api.php


how to create php mysql connection with object

<?php
$host ='localhost';
$username ='username?';
$password ='password?';
$db = 'databasename?';
$con = new mysqli($host, $username, $password, $db);
if(mysqli_error($con))
{
printf("Connect failed %s\n",mysqli_connect_error());
}
?>

Tuesday 2 August 2016

how to send email with html formate in php wordpress

$message = '<html><body>';
$message .= '<img src="http://css-tricks.com/examples/WebsiteChangeRequestForm/images/wcrf-header.png" alt="Website Booking Request" />';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr style='background: #eee;'><td><strong>First Name:</strong> </td><td>" . strip_tags($_POST['firstname']) . "</td></tr>";
$message .= "<tr style='background: #eee;'><td><strong>Last Name:</strong> </td><td>" . strip_tags($_POST['lastname']) . "</td></tr>";
$message .= "<tr><td><strong>Email:</strong> </td><td>" . strip_tags($_POST['email']) . "</td></tr>";
$message .= "<tr><td><strong>Phone No:</strong> </td><td>" . strip_tags($_POST['phone']) . "</td></tr>";
$message .= "<tr><td><strong>Address:</strong> </td><td>" . strip_tags($_POST['address']) . "</td></tr>";
$message .= "<tr><td><strong>city:</strong> </td><td>" . strip_tags($_POST['city']) . "</td></tr>";
$message .= "<tr><td><strong>state:</strong> </td><td>" . $_POST['state'] . "</td></tr>";
$message .= "<tr><td><strong>Zip Code:</strong> </td><td>" . htmlentities($_POST['zipcode']) . "</td></tr>";
$message .= "<tr><td><strong>Comming Date:</strong> </td><td>" . htmlentities($_POST['choose_date']) . "</td></tr>";
$message .= "<tr><td><strong><h3 style='background: #eee;'>Booking Add Successfull</h3></strong> </td><td>";
$message .= "</table>";
$message .= "</body></html>";

//  MAKE SURE THE "FROM" EMAIL ADDRESS DOESN'T HAVE ANY NASTY STUFF IN IT

$pattern = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i";
         if (preg_match($pattern, trim(strip_tags($_POST['email'])))) {
            $cleanedFrom = trim(strip_tags($_POST['email']));
          } else {
             return "The email address you entered was invalid. Please try again!";
           }

            //   CHANGE THE BELOW VARIABLES TO YOUR NEEDS
           
$to = "you emai id ";

$subject = 'subject';

$headers = "From: " . $cleanedFrom . "\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['email']) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

            if (wp_mail($to, $subject, $message, $headers)) {
              echo 'email send successfull.';
            } else {
              echo 'There was a problem sending the email.';
            }

NOTE : if You code is use in php only use mail($to, $subject, $message, $headers) function.
  

Monday 1 August 2016

how to integrate paypal in php

    NOTE: Follow some Step:
1. Log in to your PayPal account at https://www.paypal.com. The My Account Overview page appears.
 2.  Click the Profile subtab. The Profile Summary page appears.
 3.  Click the My Selling Tools link in the left column.
 4.  Under the Selling Online section, click the Update link in the row for Website Preferences. The Website Payment Preferences page appears
 5. Under Auto Return for Website Payments, click the On radio button to enable Auto Return.
 6.  In the Return URL field, enter the URL to which you want your payers redirected after they complete their payments. NOTE: PayPal checks the Return URL that you enter. If the URL is not properly formatted or cannot be validated, PayPal will not activate Auto Return.
7.    Scroll to the bottom of the page, and click the Save button.

8. show all post data like confirmation message get (redirect url page ) 


      $ammout = "your account like $10";
     $paypal_url='https://www.paypal.com/cgi-bin/webscr'; // Test Paypal API URL
        $paypal_id='info@gmail.com'; // Business email ID

       $paypal_url='https://www.sandbox.paypal.com/cgi-bin/webscr'; // Test Paypal API URL
       $paypal_id='mminfo@.com'; // Business email ID 


        <form method="post" action='<?php echo $paypal_url; ?>'>
         <input type='hidden' name='business' value='<?php echo $paypal_id; ?>'>    
        <input type='hidden' name='cmd' value='_xclick'>
          <br/>
         <input type='hidden' name='item_name' value='Tour-package'>
           <input type='hidden' name='item_number' value='001'>
         <input type='hidden' name='amount' value='<?php echo $amount; ?>'>
         <input type='hidden' name='rest_amount' value='<?php echo $rest_amount; ?>'>
         <input type='hidden' name='cancel_return' value='<?php echo $site_url;?>/cancel'>
         <input type='hidden' name='custemail' value='<?php echo $email; ?>'>
         <input type="hidden" name="rm" value="2">
         <input type="submit" class="sbt-btn-book" name="member-submit" class="sub-btn" value="Submit">
       </form>