Monday 11 January 2016

Setting various environments (development, production) based on the URL


<?php


    define('DEVELOPMENT', 'localhost');
    define('PRODUCTION', '');
    $message = "";
    switch ($_SERVER['SERVER_NAME']) {
      case DEVELOPMENT:
        // Condition for localhost server
        $localhost = "localhost";
        $username = "root";
        $password = "";
        $database = "test";
        break;
    default:
        // live server
        $localhost = "Enter live hostname";
        $username = "Enter live username";
        $password = "Enter live password";
        $database = "Enter live database name";
        break;
    }
$GLOBALS['connection'] = new mysqli($localhost, $username, $password, $database);

if($GLOBALS['connection'])
{
     echo "connected";
}
else{
     echo mysqli_error();
}


?>

Thursday 7 January 2016

how to reduce server side validation code in php


You can do server side validation code in if...else condition also.
But below code will reduce your code in server side validation also gives result with comma(,).
Run this code and you see magic.
Here, validation will check only for four fields. Not for Phone number.

Example : First name, Middle name, Last name, Email is require.


// Database query
CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET latin1 */

// Table query
CREATE TABLE `candidate1` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `site_id` int(11) NOT NULL DEFAULT '0',
 `last_name` varchar(64) ,
 `first_name` varchar(64) ,
 `middle_name` varchar(32) ,
 `phone_home` varchar(40) ,
 `email1` varchar(128),

 PRIMARY KEY (`id`)
)

Form1.php
<?php
if(isset($_POST['job_form_submit']))
{
    $first_name = $_REQUEST['first_name'];
    $middle_name = $_REQUEST['middle_name'];
    $last_name = $_REQUEST['last_name'];
    $email1 = $_REQUEST['email'];
    $phone_home = $_REQUEST['phone_home'];

    $result = '';
    //Validations
    $fields = array('first_name'=>$first_name,'middle_name'=>$middle_name, 'last_name'=>$last_name, 'email'=>$email1);
    foreach($fields as $key => $val) {
      if(empty($val)){
          $result .= ucfirst (str_replace("_"," ",$key)) . ", ";
      }
     }
     if(empty($result)){
        // insert values in candidate table
        $insert = mysqli_query($conn, "insert into candidate(first_name, middle_name, last_name, email1, phone_home) values ('".$first_name."', '".$middle_name."', '".$last_name."', '".$email1."', '".$phone_home."')");       
        if ($insert) {
        echo "New record created successfully";
        } else {
            echo "Error: ".mysqli_error($conn);
        }
        $conn->close();
     }
     else{
        echo rtrim($result,", ")." is require.";
    }   
}

?>

<form name="" method="post" id="frm_job" action="">
  <!-- Start: First Name -->
  <fieldset class="form-group">
    <label for="firstname">First Name</label>
    <input type="text" name="first_name" value="" class="form-control" id="txt_firstname" placeholder="Enter First Name">
  </fieldset>
  <!-- End: First Name -->

  <!-- Start: Middle Name -->
  <fieldset class="form-group">
    <label for="middlename">Middle Name</label>
    <input type="text" name="middle_name" value="" class="form-control" id="txt_middlename" placeholder="Enter Middle Name">
  </fieldset>
  <!-- End: Middle Name -->
 
  <!-- Start: Last Name -->
  <fieldset class="form-group">
    <label for="lastname">Last Name</label>
    <input type="text" name="last_name" value=""class="form-control" id="txt_lastname" placeholder="Enter Last Name">
  </fieldset>
  <!-- End: Last Name -->
 
  <!-- Start: Email -->
  <fieldset class="form-group">
    <label for="email">Email</label>
    <input type="text" name="email" value="" class="form-control" id="txt_email" placeholder="Enter Email">
  </fieldset>
  <!-- End: Email -->
 
  <!-- Start: Home Phone -->
  <fieldset class="form-group">
    <label for="homephone">Home Phone</label>
    <input type="text" name="phone_home" value="" class="form-control" id="txt_homephone" placeholder="Enter Home Phone">
  </fieldset>
  <!-- End: Home Phone -->
 
  <button type="submit" value="submit" name="job_form_submit" class="btn btn-primary">Submit</button>
  <button type="reset" class="btn btn-default">Reset</button>
</form>

Saturday 29 August 2015

Turn off error reporting

error_reporting(0);
//write this on top of the page

http://www.w3schools.com/php/func_error_reporting.asp

change color when u select TEXT

/* Mozilla based browsers */
::-moz-selection {
background-color: #FFA;
color: #000;
}

/* Works in Safari */
::selection {
background-color: #FFA;
color: #000;
}


http://css-tricks.com/overriding-the-default-text-selection-color-with-css/

decimal number settings

$total_of_product = $order_info['total'];
echo $total_db = number_format($total_of_product, 2, '.', '');

how to add FONT in wordpress

------------insert in style.css
@font-face {
font-family: 'MuseoSlab';
src: url('http://localhost:81/wordpress/fonts/Museo_Slab_500_2-webfont.eot');
src: url('http://localhost:81/wordpress/fonts/Museo_Slab_500_2-webfont.eot?#iefix') format('embedded-opentype'),
url('http://localhost:81/wordpress/fonts/Museo_Slab_500_2-webfont.woff') format('woff'),
url('http://localhost:81/wordpress/fonts/Museo_Slab_500_2-webfont.ttf') format('truetype'),
url('http://localhost:81/wordpress/fonts/Museo_Slab_500_2-webfont.svg#MuseoSlab') format('svg');
font-weight: normal;
font-style: normal;
}


http://www.fontspring.com/support/installing_webfonts/how-do-i-use-the-webfonts

download WORDPRESS paid themes in free OF COST

search in Google

free download nulled evolution theme for wordpress

--nulled is compulsory

--evolution is theme name

Other words are static


https://www.google.co.in/search?q=evolution+theame+for+wordpress&ie=utf-8&oe=utf-8&gws_rd=cr&ei=VKW8VO6SEsmj8AX5lIDQCw#q=free+download+nulled+evolution+theme+for+wordpress