Showing posts with label PHP simple task. Show all posts
Showing posts with label PHP simple task. Show all posts

One Page Template Scrolling Script

One Page Template Scrolling Script


Hi Today discussed Bootstrap template one page template Scrollig Script url passing id and the scroll script.Follow us script.

One Page Template Scrolling Script
One Page Template Scrolling Script


JavaScript

<script type="text/javascript">
!function(t){"use strict";t("a.page-scroll").bind("click",function(a){var o=t(this);t("html, body").stop().animate({scrollTop:t(o.attr("href")).offset().top-50},1250,"easeInOutExpo"),a.preventDefault()}),t("body").scrollspy({target:".navbar-fixed-top",offset:51}),t(".navbar-collapse ul li a").click(function(){t(".navbar-toggle:visible").click()}),t("#mainNav").affix({offset:{top:100}})}(jQuery);
</script>

How to Import and Export CSV Files Using PHP and MySQL

How to Import and Export CSV Files Using PHP and MySQL


Hi Today discussed PHP Server side Scripting Language How to Import and Export CSV Files using PHP and mysql. Database normally insert and update and delete queries and bulk insert it's means csv file same column file data csv file data insert mysql. code follows.


How to Import and Export CSV Files Using PHP and MySQL
How to Import and Export CSV Files Using PHP and MySQL



First Create database and then create table.

CREATE DATABASE employee
Create table

CREATE TABLE employeedetils(
eid VARCHAR(50) UNSIGNED PRIMARY KEY,
firstname VARCHAR(30) NOT NULL,
lastname VARCHAR(30) NOT NULL,
email VARCHAR(50),
create_date VARCHAR(50)
)
dbconnect

<?php
function getdb(){
$servername = "localhost";
$username = "root";
$password = "";
$db = "employee";

try {
   
    $conn = mysqli_connect($servername, $username, $password, $db);
     //echo "Connected successfully"; 
    }
catch(exception $e)
    {
    echo "Connection failed: " . $e->getMessage();
    }
    return $conn;
}
?>
PHP File Import function phpfiles.php

<?php


 if(isset($_POST["Import"])){
  
  $filename=$_FILES["file"]["tmp_name"];  


   if($_FILES["file"]["size"] > 0)
   {
     $file = fopen($filename, "r");
         while (($getData = fgetcsv($file, 10000, ",")) !== FALSE)
          {


            $sql = "INSERT into employeedetils(eid,firstname,lastname,email,create_date)                    values ('".$getData[0]."','".$getData[1]."','".$getData[2]."','".$getData[3]."','".$getData[4]."')";
                   $result = mysqli_query($con, $sql);
    if(!isset($result))
    {
     echo "<script type=\"text/javascript\">
       alert(\"Invalid File:Please Upload CSV File.\");
       window.location = \"index.php\"
        </script>";  
    }
    else {
       echo "<script type=\"text/javascript\">
      alert(\"CSV File has been successfully Imported.\");
      window.location = \"index.php\"
     </script>";
    }
          }
   
          fclose($file); 
   }
 }  


 ?>

View Page design bootstrap lib include

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" crossorigin="anonymous"></script>
View Page


<!DOCTYPE html>
<html lang="en">

<head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" crossorigin="anonymous">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" crossorigin="anonymous">
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" crossorigin="anonymous"></script>

</head>

<body>
    <div id="wrap">
        <div class="container">
            <div class="row">

                <form class="form-horizontal" action="phpfiles.php" method="post" name="upload_excel" enctype="multipart/form-data">
                    <fieldset>

                        <!-- Form Name -->
                        <legend>Form Name</legend>

                        <!-- File Button -->
                        <div class="form-group">
                            <label class="col-md-4 control-label" for="filebutton">Select File</label>
                            <div class="col-md-4">
                                <input type="file" name="file" id="file" class="input-large">
                            </div>
                        </div>

                        <!-- Button -->
                        <div class="form-group">
                            <label class="col-md-4 control-label" for="singlebutton">Import data</label>
                            <div class="col-md-4">
                                <button type="submit" id="submit" name="Import" class="btn btn-primary button-loading" data-loading-text="Loading...">Import</button>
                            </div>
                        </div>

                    </fieldset>
                </form>

            </div>
            <?php
               getdbrecords();
            ?>
        </div>
    </div>
</body>

</html>
view php records

function getdbrecords(){
    $con = getdb();
    $Sql = "SELECT * FROM employeedetils";
    $result = mysqli_query($con, $Sql);  


    if (mysqli_num_rows($result) > 0) {
     echo "<div class='table-responsive'><table id='myTable' class='table table-striped table-bordered'>
             <thead><tr><th>EMP ID</th>
                          <th>First Name</th>
                          <th>Last Name</th>
                          <th>Email</th>
                          <th>Registration Date</th>
                        </tr></thead><tbody>";


     while($row = mysqli_fetch_assoc($result)) {

         echo "<tr><td>" . $row['eid']."</td>
                   <td>" . $row['firstname']."</td>
                   <td>" . $row['lastname']."</td>
                   <td>" . $row['email']."</td>
                   <td>" . $row['create_date']."</td></tr>";        
     }
    
     echo "</tbody></table></div>";
     
} else {
     echo "you have no records";
}
}

Export MySQL to CSV With PHP

<div>
            <form class="form-horizontal" action="phpfiles.php" method="post" name="upload_excel"   
                      enctype="multipart/form-data">
                  <div class="form-group">
                            <div class="col-md-4 col-md-offset-4">
                                <input type="submit" name="Export" class="btn btn-success" value="export to excel"/>
                            </div>
                   </div>                    
            </form>           
 </div>
Export Functions

if(isset($_POST["Export"])){
   
      header('Content-Type: text/csv; charset=utf-8');  
      header('Content-Disposition: attachment; filename=data.csv');  
      $output = fopen("php://output", "w");  
      fputcsv($output, array('ID', 'First Name', 'Last Name', 'Email', 'Joining Date'));  
      $query = "SELECT * from employeedetils ORDER BY emp_id DESC";  
      $result = mysqli_query($con, $query);  
      while($row = mysqli_fetch_assoc($result))  
      {  
           fputcsv($output, $row);  
      }  
      fclose($output);  
 }  

Ionic Framework Paypal Payment Gateway

Ionic Framework Paypal Payment Gateway


Today Discussed Ionic Framework Paypal payment Gateway. First  Ionic Framework Cordova Plugin. and How to get payment gateway integrated follows. 
Ionic Framework Paypal Payment Gateway
Ionic Framework Paypal Payment Gateway
IK have developed a mobile app using ionic framework and cordova. In my backend mysql. and storing data using php code. Cordova Plugin ClientID here  api keys.

 $scope.buyNow = function ()
    {
        PaypalService.initPaymentUI().then(function () { PaypalService.makePayment(50, "Total").then();       });
    }
PaypalService is implemented as 
ngular.module('starter.PaypalService', ['starter.Constants'])
.factory('PaypalService', ['$q', '$ionicPlatform','Constants', '$filter', '$timeout', function ($q, $ionicPlatform, Constants, $filter, $timeout) {



    var init_defer;
    /**
     * Service object
     * @type object
     */
    var service = {
        initPaymentUI: initPaymentUI,
        createPayment: createPayment,
        configuration: configuration,
        onPayPalMobileInit: onPayPalMobileInit,
        makePayment: makePayment
    };


    /**
     * @ngdoc method
     * @name initPaymentUI
     * @methodOf app.PaypalService
     * @description
     * Inits the payapl ui with certain envs.
     *
     *
     * @returns {object} Promise paypal ui init done
     */
    function initPaymentUI() {

        init_defer = $q.defer();
        $ionicPlatform.ready().then(function () {

            var clientIDs = {
                "PayPalEnvironmentProduction": Constants.payPalProductionId,
                "PayPalEnvironmentSandbox": Constants.payPalSandboxId
            };
            PayPalMobile.init(clientIDs, onPayPalMobileInit);
        });

        return init_defer.promise;
    }

    /**
     * @ngdoc method
     * @name createPayment
     * @methodOf app.PaypalService
     * @param {string|number} total total sum. Pattern 12.23
     * @param {string} name name of the item in paypal
     * @description
     * Creates a paypal payment object
     *
     *
     * @returns {object} PayPalPaymentObject
     */
    function createPayment(total, name) {

        // "Sale  == >  immediate payment
        // "Auth" for payment authorization only, to be captured separately at a later time.
        // "Order" for taking an order, with authorization and capture to be done separately at a later time.
        var payment = new PayPalPayment("" + total, "INR", "" + name, "Sale");
        return payment;
    }
    /**
     * @ngdoc method
     * @name configuration
     * @methodOf app.PaypalService
     * @description
     * Helper to create a paypal configuration object
     *
     *
     * @returns {object} PayPal configuration
     */
    function configuration() {
        // for more options see `paypal-mobile-js-helper.js`
        var config = new PayPalConfiguration({merchantName: Constants.payPalShopName, merchantPrivacyPolicyURL: Constants.payPalMerchantPrivacyPolicyURL, merchantUserAgreementURL: Constants.payPalMerchantUserAgreementURL});
        return config;
    }

    function onPayPalMobileInit() {
        $ionicPlatform.ready().then(function () {
            // must be called
            // use PayPalEnvironmentNoNetwork mode to get look and feel of the flow
            PayPalMobile.prepareToRender(Constants.payPalEnv, configuration(), function () {

                $timeout(function () {
                    init_defer.resolve();
                });

            });
        });
    }
    /**
     * @ngdoc method
     * @name makePayment
     * @methodOf app.PaypalService
     * @param {string|number} total total sum. Pattern 12.23
     * @param {string} name name of the item in paypal
     * @description
     * Performs a paypal single payment
     *
     *
     * @returns {object} Promise gets resolved on successful payment, rejected on error
     */
    function makePayment(total, name) {


        var defer = $q.defer();
        total = $filter('number')(total, 2);
        $ionicPlatform.ready().then(function () {
            PayPalMobile.renderSinglePaymentUI(createPayment(total, name), function (result) {
                $timeout(function () {
                    defer.resolve(result);
                });
            }, function (error) {
                $timeout(function () {
                    defer.reject(error);
                });
            });
        });

        return defer.promise;
    }

    return service;
}]);
Followed Step

API Backend and Integrations

Every app talks to a server or backed and Appery.io provides a complete backend for your app:

  • Database - for storing app data.
  • Server Code - for writing app logic on the server using JavaScript.
  • API Express - exposing enterprise data sources such as an SQL database or SOAP service via REST APIs. Also, build advanced services with a visual service editor.
  • Push Notifications - send Push Notifications to your users.

Crop Image in Core PHP

Crop Image in Core PHP

Today Discussed Crop Image in Core PHP. Image crop and create thumb image and upload save particular directory. crop this image and resize compressed image save a directory. code follow us. 
Crop Image in Core PHP
Crop Image in Core PHP
$upload_dir = "upload_pic";     // The directory for the images to be saved in
$upload_path = $upload_dir."/";    // The path to where the image will be saved
$large_image_prefix = "resize_";    // The prefix name to large image
$thumb_image_prefix = "thumbnail_";   // The prefix name to the thumb image
$large_image_name = $large_image_prefix.$_SESSION['random_key'];     // New name of the large image (append the timestamp to the filename)
$thumb_image_name = $thumb_image_prefix.$_SESSION['random_key'];     // New name of the thumbnail image (append the timestamp to the filename)
$max_file = "3";        // Maximum file size in MB
$max_width = "500";       // Max width allowed for the large image
$thumb_width = "100";      // Width of thumbnail image
$thumb_height = "100";      // Height of thumbnail image
// Only one of these image types should be allowed for upload
$allowed_image_types = array('image/pjpeg'=>"jpg",'image/jpeg'=>"jpg",'image/jpg'=>"jpg",'image/png'=>"png",'image/x-png'=>"png",'image/gif'=>"gif");
$allowed_image_ext = array_unique($allowed_image_types); // do not change this
$image_ext = ""; // initialise variable, do not change this.
foreach ($allowed_image_ext as $mime_type => $ext) {
    $image_ext.= strtoupper($ext)." ";
}

Image Resize Function


function resizeImage($image,$width,$height,$scale) {
 list($imagewidth, $imageheight, $imageType) = getimagesize($image);
 $imageType = image_type_to_mime_type($imageType);
 $newImageWidth = ceil($width * $scale);
 $newImageHeight = ceil($height * $scale);
 $newImage = imagecreatetruecolor($newImageWidth,$newImageHeight);
 switch($imageType) {
  case "image/gif":
   $source=imagecreatefromgif($image); 
   break;
     case "image/pjpeg":
  case "image/jpeg":
  case "image/jpg":
   $source=imagecreatefromjpeg($image); 
   break;
     case "image/png":
  case "image/x-png":
   $source=imagecreatefrompng($image); 
   break;
   }
 imagecopyresampled($newImage,$source,0,0,0,0,$newImageWidth,$newImageHeight,$width,$height);
 
 switch($imageType) {
  case "image/gif":
     imagegif($newImage,$image); 
   break;
       case "image/pjpeg":
  case "image/jpeg":
  case "image/jpg":
     imagejpeg($newImage,$image,90); 
   break;
  case "image/png":
  case "image/x-png":
   imagepng($newImage,$image);  
   break;
    }
 
 chmod($image, 0777);
 return $image;
}
Resize Thumbnail Image Function

function resizeImage($image,$width,$height,$scale) {
 list($imagewidth, $imageheight, $imageType) = getimagesize($image);
 $imageType = image_type_to_mime_type($imageType);
 $newImageWidth = ceil($width * $scale);
 $newImageHeight = ceil($height * $scale);
 $newImage = imagecreatetruecolor($newImageWidth,$newImageHeight);
 switch($imageType) {
  case "image/gif":
   $source=imagecreatefromgif($image); 
   break;
     case "image/pjpeg":
  case "image/jpeg":
  case "image/jpg":
   $source=imagecreatefromjpeg($image); 
   break;
     case "image/png":
  case "image/x-png":
   $source=imagecreatefrompng($image); 
   break;
   }
 imagecopyresampled($newImage,$source,0,0,0,0,$newImageWidth,$newImageHeight,$width,$height);
 
 switch($imageType) {
  case "image/gif":
     imagegif($newImage,$image); 
   break;
       case "image/pjpeg":
  case "image/jpeg":
  case "image/jpg":
     imagejpeg($newImage,$image,90); 
   break;
  case "image/png":
  case "image/x-png":
   imagepng($newImage,$image);  
   break;
    }
 
 chmod($image, 0777);
 return $image;
}
function getHeight($image) {
 $size = getimagesize($image);
 $height = $size[1];
 return $height;
}
//You do not need to alter these functions
function getWidth($image) {
 $size = getimagesize($image);
 $width = $size[0];
 return $width;
}

if (isset($_POST["upload_thumbnail"]) && strlen($large_photo_exists)>0) {
 //Get the new coordinates to crop the image.
 $x1 = $_POST["x1"];
 $y1 = $_POST["y1"];
 $x2 = $_POST["x2"];
 $y2 = $_POST["y2"];
 $w = $_POST["w"];
 $h = $_POST["h"];
 //Scale the image to the thumb_width set above
 $scale = $thumb_width/$w;
 $cropped = resizeThumbnailImage($thumb_image_location, $large_image_location,$w,$h,$x1,$y1,$scale);
 //Reload the page again to view the thumbnail
 header("location:".$_SERVER["PHP_SELF"]);
 exit();
}


if ($_GET['a']=="delete" && strlen($_GET['t'])>0){
//get the file locations 
 $large_image_location = $upload_path.$large_image_prefix.$_GET['t'];
 $thumb_image_location = $upload_path.$thumb_image_prefix.$_GET['t'];
 if (file_exists($large_image_location)) {
  unlink($large_image_location);
 }
 if (file_exists($thumb_image_location)) {
  unlink($thumb_image_location);
 }
 header("location:".$_SERVER["PHP_SELF"]);
 exit(); 
}
view.html

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
 <meta name="generator" content="WebMotionUK" />
 <title>WebMotionUK - PHP &amp; Jquery image upload &amp; crop</title>
 <script type="text/javascript" src="js/jquery-pack.js"></script>
 <script type="text/javascript" src="js/jquery.imgareaselect.min.js"></script>
</head>
<body>

PHP Image delete Common Function Jquery Ajax Call

PHP Image delete Common Function Jquery Ajax Call


Today Discussed PHP Image delete Common Function Jquery Ajax Call Normal Core PHP Commonly Write one function just put table name and primary id and path get delete the image and unlink this page follows code.

PHP Image delete Common Function Jquery Ajax Call
PHP Image delete Common Function Jquery Ajax Call


Form.php

 <div class="col-md-6" id="delimage">
                                    <label> </label>
                                    <?php if (getprofile('image', $_SESSION['UID']) != '') { ?>
                                                                                        <img src="<?php echo $sitename . 'pages/profile/image/' . getprofile('image', $_SESSION['UID']); ?>" style="padding-bottom:10px;" height="100" /><!--&nbsp;<buttton type="button" style="cursor:pointer;" class="btn btn-danger" name="del" id="del" onclick="javascript:dellocationimage();"><i class="fa fa-close">&nbsp;Delete Image</i></buttton>-->
                                        <button type="button" style="cursor:pointer;" class="btn btn-danger" name="del" id="del" onclick="javascript:deleteimage('<?php echo getprofile('image', $_SESSION['UID']); ?>', '<?php echo $_SESSION['UID']; ?>', 'manageprofile', '../pages/profile/image/', 'image', 'pid');"><i class="fa fa-close">&nbsp;Delete Image</i></button>
                                    <?php } ?>
                                </div>
Ajax.js(Javascript)
function deleteimage(a, b, c, d, e, f)
{
    if (window.XMLHttpRequest)
    {
        oRequestsubcat = new XMLHttpRequest();
    } else if (window.ActiveXObject)
    {
        oRequestsubcat = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if (a != '' && b != '' && c != '' && d !='' && e !=''&& f !='')
    {
        document.getElementById("delimage").innerHTML = '<div class="overlay"><i class="fa fa-refresh fa-spin"></i></div>';
        oRequestsubcat.open("POST", Settings.base_url + "config/functions_ajax.php", true);
        oRequestsubcat.onreadystatechange = delimg;
        oRequestsubcat.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        oRequestsubcat.send("image=" + a + "&id=" + b + "&table=" +c + "&path=" + d + "&images=" +e + "&pid=" + f);
        console.log(a,b,c,d,e,f);
    }
}
function delimg()
{
    if (oRequestsubcat.readyState == 4)
    {
        if (oRequestsubcat.status == 200)
        {
            document.getElementById("delimage").innerHTML = oRequestsubcat.responseText;
        }
        else
        {
            document.getElementById("delimage").innerHTML = oRequestsubcat.responseText;
        }
    }
}
or

Ajax.js(Jquery)
function deleteimage(a,b,c,d)
{
    $.post(Settings.base_url + "config/functions_ajax.php",{ a:a,b:b,c:c,d:d },function(data){
        console.log(data);
        $('#delimage').html(data);
        //alert(data);
    });
}

Function.php

if (($_REQUEST['image'] != '') && ($_REQUEST['id'] != '') && ($_REQUEST['table'] != '')&& ($_REQUEST['path'] != '')&& ($_REQUEST['images'] != '')&& ($_REQUEST['pid'] != '')) {
    unlink($_REQUEST['path'].$_REQUEST['image']);
 // $s = "UPDATE `".$_REQUEST['table']."` SET `".$_REQUEST['images']."`='' WHERE `".$_REQUEST['pid']."`='" . $_REQUEST['id'] . "'";
   // echo $s;
    //return $s;
   // exit;
    DB("UPDATE `".$_REQUEST['table']."` SET `".$_REQUEST['images']."`='' WHERE `pid`='" . $_REQUEST['id'] . "'");
    DB("INSERT `history` (`page`,`pageid`,`action`,`userid`,`ip`,`actionid`,`info`) VALUES ('Manage Profile','9','Delete','" . $_SESSION['UID'] . "','" . $_SERVER['REMOTE_ADDR'] . "','" . $_REQUEST['b'] . "','Image Deletion')");
  echo '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><h4><i class="icon fa fa-close"></i>Succesfully Deleted</h4><!--<a href="' . $sitename . 'settings/adddepartment.htm">Add another one</a>--></div>';

PHP Security ImagesCaptcha

PHP security imagesCaptcha

PHP Security imagesCaptcha is a simple test to determine if a user is a computer or a human.  It is used to prevent spam abuse on the websites. Just Avoid spamers and crackers in the sites. So if you use CAPTCHA on your web forms, this can help in stopping some bots and making life harder for other bots in accessing or using your forms. Normal Core PHP simple Shopping Cart

PHP security imagesCaptcha
PHP security imagesCaptcha


Captcha.php

<?php
session_start();
class CaptchaSecurityImages {

 var $font = 'monofont.ttf';

 function generateCode($characters) {
  /* list all possible characters, similar looking characters and vowels have been removed */
  $possible = '23456789bcdfghjkmnpqrstvwxyz';
  $code = '';
  $i = 0;
  while ($i < $characters) { 
   $code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
   $i++;
  }
  return $code;
 }

 function CaptchaSecurityImages($width='60',$height='50',$characters='5') {
  $code = $this->generateCode($characters);
  /* font size will be 75% of the image height */
  $font_size = $height * 0.85;
  $image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
  /* set the colours */
  $background_color = imagecolorallocate($image, 255, 255, 255);
  $text_color = imagecolorallocate($image, 20, 40, 100);
  $noise_color = imagecolorallocate($image, 200, 200, 200);
  /* generate random dots in background */
  for( $i=0; $i<($width*$height)/3; $i++ ) {
   imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color);
  }
  /* generate random lines in background */
  for( $i=0; $i<($width*$height)/150; $i++ ) {
   imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
  }
  /* create textbox and add text */
  $textbox = imagettfbbox($font_size, 0, $this->font, $code) or die('Error in imagettfbbox function');
  $x = ($width - $textbox[4])/2;
  $y = ($height - $textbox[5])/2;
  imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font , $code) or die('Error in imagettftext function');
  /* output captcha image to browser */
  header('Content-Type: image/jpeg');
  imagejpeg($image);
  imagedestroy($image);
  $_SESSION['keycode'] = $code;
 }

}

$width = isset($_GET['width']) ? $_GET['width'] : '90';
$height = isset($_GET['height']) ? $_GET['height'] : '21';
$characters = isset($_GET['characters']) && $_GET['characters'] > 1 ? $_GET['characters'] : '5';

$captcha = new CaptchaSecurityImages($width,$height,$characters);

?>
Your Form Page Added Following Script.
<script type="text/javascript">

function refreshCaptcha(abspath){

document.getElementById('refcaptimg').src="Captcha.php?t=" + new Date().getTime();

}</script>
Form

<form name="frmContact" method="post" action="contact-us.html">
<table width="175" border="0" cellpadding="2" cellspacing="0">
 <tr>
   <td  height="81" align="left" valign="middle"><a href="full_certificate.pdf" target="_blank"><img src="images/svc.gif" alt="" border="0"/></a></td>

  </tr>
<tr>

<td style="padding-bottom:10px;">
<div>
<!-- End Comm100 Live Chat Button Code -->

</td>
  </tr>

  <tr>
    <td class="page_heading"> </td>
  </tr>
  <tr>

   <td class="fnt_sml" style="padding-top:10px;"><img src="images/FORM/OPT-1.png" width="39" height="8" /><span style="color:#FF0000"></span></td>
  </tr>
  <tr>
   <td  ><input type="text" name="Name" id="Name" class="input_left" value='<?php echo $LastName?>' />
<span style="clear:left;" class="input_left_error" ><?php echo $msgName?></span></td>
  </tr>
 <tr>
    <td class="fnt_sml"><img src="images/FORM/OPT-3.png" /></span></td>

  </tr>
  <tr>
    <td><input type="text" name="Email" id="Email" class="input_left" value='<?php echo $Email ?>' />

<span style="clear:left;" class="input_left_error" ><?php echo $msgEmail ?></span></td>

  </tr>
  <tr>
    <td class="fnt_sml"><img src="images/FORM/OPT-4.png" /></td>
  </tr>
  <tr>
    <td><input type="text" name="Phone" id="Phone" class="input_left" value='<?php echo $Phone ?>' />

<span style="clear:left;" class="input_left_error" ><?php echo $msgPhone ?></span></td>

  </tr>
  <tr>
   <td class="fnt_sml"><img src="images/FORM/OPT-5.png" width="57" height="10" /></td>

  </tr>
  <tr>
    <td class="fnt_sml"><input type="text" name="TelPhone" class="input_left" id="TelPhone" value='<?php echo $TelPhone?>' />
    <span style="clear:left;" class="input_left_error"><?php echo $msgTelPhone ?></span></td>
  </tr>
 <tr>
   <td class="fnt_sml"><img src="images/FORM/OPT-2.png" /></td>

  </tr>
  <tr>
    <td><textarea name="Message" id="Message" rows="5" cols="25" class="input_left" value='<?php echo $Message?>'></textarea>

<span style="clear:left;" class="input_left_error" ><?php echo $msgMessage ?></span></td>
   </tr>
  <tr>
    <td class="fnt_sml"><img src="images/FORM/OPT-6.png" width="89" height="8" /></td>

  </tr>
  <tr>
    <td align="center"><input type="text" name="keycode" id="keycode" size="20" class="input_left" style="width:170px;" value='<?php echo $keycode ?>' />

<span style="clear:left;" class="input_left_error" > <?php echo $msgkeycode ?> </span>

<img src="CaptchaSecurityImages.php" id="refcaptimg" align="middle" style="margin-top:5px;" alt="" />&nbsp;<a href="javascript:refreshCaptcha('images/')"><img  src="images/hip_reload.gif" width="22" height="22" border="0" align="middle" style="margin-top:1px;" alt="" /></a>
          <a href="javascript:refreshCaptcha('images/')"><span class="style1" style="color: #FE4819"></span></a>

      <div class="input_left_error"></div></td>
  </tr>
  <tr>
    <td align="center"><input type="submit" name="Submit" value="Submit" style="background-color:#2172B8; color:#ffffff; border:solid 1px #2172B8;" />
</td>
</tr>
</table>
</form>

PHP Code Follow us : Contact-us.php

<?php if(isset($_POST[Submit])){

if(empty($_POST[Name])){$msgName='Please Enter Your Name.'; $Name= false;}
 else{$Name=$_POST[Name];}

if(empty($_POST[Message])) {$msgMessage= 'Please Enter your message.'; $Message=false; }
       else{$Message=$_POST[Message];}

if(empty($_POST[Email])){$msgEmail='Please Enter Your Email-Id';$Email= false; }
 else{$Email=$_POST[Email];}
 if (!eregi("^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.([a-zA-Z]{2,4})$", $_POST[Email])){ $msgEmail= 'Please Enter A Valid Email Address'; $Email = false; }
 else{$Email=$_POST[Email];}

if(empty($_POST[Phone])){$msgPhone='Please Enter Your Contact No. '; $Phone= false;}
 else{$Phone=$_POST[Phone];}
 if(!eregi("[0-9.-\+]", $_POST[Phone])) {$msgPhone='Please enter a valid contact no. '; $Phone=false;}
 else{ $Phone=$_POST[Phone];}

 $TelPhone=$_POST[TelPhone];

if($_POST[keycode]!=$_SESSION[keycode] OR $_SESSION[keycode]==''){$msgkeycode = 'Incorrect verification code';$keycode = false;}
 else{$keycode=$_POST[keycode];}
 if($Name  && $Message && $Email && $Phone && $Message && $keycode)
 {
  header("Location: $tpage");
exit;
}else{ index.php } ?>