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> 

Sunday 31 July 2016

how to create a dynamic drop-down in wordpress

<?php
global $wpdb;
$select_query= $wpdb->get_results( 'SELECT * FROM wp_add_bed_service');
echo "<select class='form-control' id='badroom-1' name='bedroom'>";
foreach ($select_query as $select_queryy )
{
  echo "<option value='$select_queryy->price' >".htmlspecialchars($select_queryy->bedroom)."</option>";
}
echo "</select>";

?>

Thursday 28 July 2016

how to add datepiker in text field

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>
<script>
$( function() {
$( "#datepicker" ).datepicker();
} );
</script>
</head>
<body>
<p>Date: <input type="text" id="datepicker"></p>
</body>

Thursday 2 June 2016

html form with insert data in php

<html>
<head>
<link rel="stylesheet" href="int.css" />
<style>
.error {color: #FF0000;}
</style>
</head>
<body>
<?php
$i_namea = $f_namea = $emaila = $contacta= $r_filea = "";
$i_name = $f_name = $email = $contact= $r_file =  "";

if ($_SERVER["REQUEST_METHOD"] == "POST") {
   if (empty($_POST["i_name"])) {
     $i_namea = "Intervier name is required";
   } else {
     $i_name = test_input($_POST["i_name"]);
   }
 
   if (empty($_POST["f_name"])) {
     $f_namea = "father name is required";
   } else {
     $f_name = test_input($_POST["f_name"]);
   }
   
   if (empty($_POST["email"])) {
     $emaila = "email id is required";
   } else {
     $email = test_input($_POST["email"]);
   }
    if (empty($_POST["contact"])) {
     $contacta = "contact is required";
   } else {
     $contact = test_input($_POST["contact"]);
   }

   }
function test_input($data) {
   $data = trim($data);
   $data = stripslashes($data);
   $data = htmlspecialchars($data);
   return $data;
}
?>
<div id="mainform">
<!-- Required Div Starts Here -->
<form id="form" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post" enctype="multipart/form-data">
<h3>Intervier Form</h3>
<p id="returnmessage"></p>
<label>Name: <span>*</span></label>
<input type="text" name="i_name" placeholder="Name"/>
 <span class="error"><?php echo $i_namea; ?></span></br>
<label>Father Name: <span>*</span></label>
<input type="text" name="f_name" placeholder="father Name"/>
 <span class="error"><?php echo $f_namea; ?></span></br>
<label>Email: <span>*</span></label>
<input type="text" name="email" placeholder="Email"/>
<span class="error"><?php echo $emaila; ?></span></br>
<label>Contact No: <span>*</span></label>
<input type="text" name="contact" placeholder="10 digit Mobile no."/>
 <span class="error"><?php echo $contacta; ?></span></br>
<label>Resume: <span>*</span></label>
<input type="file" name="r_file">
<input type="hidden" name='id' value="<?php echo $_GET['id']; ?>" >
<input type="submit" name="submit" value="submit"/>
<a href="profile.php"><input type="button" name="" value="back"></a>
</form>
</div>
</body>
</html>
<?php include 'db.php' ?>
<?php
 if(isset($_POST['submit']))
 {
$i_name=$_POST['i_name'];
$f_name =$_POST['f_name'];
$email =$_POST['email'];
$contact =$_POST['contact'];
$info = pathinfo($_FILES['r_file']['name']);
$ext = $info['extension'];
$newname =  uniqid().".".$ext;
$target = 'name/'.$newname;
 move_uploaded_file( $_FILES['r_file']['tmp_name'], $target);
$sql="INSERT INTO inter_detail (i_name ,f_name, email, contact, r_file) VALUES ('$i_name', '$f_name', '$email','$contact','$newname')";
mysql_query($sql) or die(mysql_error());
}
?>