Saturday, 28 June 2014

PHP - Header redirect issue Occur in Live Server

Method I

<?php ob_start(); if(isset($_GET['elimina_id'])){ if (in_array($_GET['elimina_id'], $_SESSION['cart']) ) { $index = (array_keys($_SESSION['cart'], $_GET['elimina_id'])); $i = $index[0]; unset($_SESSION['cart'][$i]); header('location: cart.php'); } } ob_end_flush(); ?>

Method II

HTML: <meta http-equiv="refresh" content="0;url=http://www.site.com/cart.php"> JavaScript #1: <script>window.location = "http://www.site.com/cart.php";</script> JavaScript #2: <script>window.navigate("http://www.site.com/cart.php");</script>

Wednesday, 25 June 2014

Set Position of Bootstrap Modal Popup

@media screen and (min-width: 768px) {
    .modal-dialog {
        left: 50%;
        right: auto;
        width: 624px;
    }
}
.modal-dialog{
position: absolute;
left: 50%;
//now you must set a margin left under zero - value is a half width your window
margin-left: -312px;
// this same situation is with height - example
height: 500px;
top: 50%;
margin-top: -250px;
} 

Alphanumeric Validation

Enter text filed only to allow alphabit & Numbers 
function alpha_numeric_validation(arg){
 var valReg = /^[A-Za-z0-9]+$/;
 if(valReg.test( arg ) ) {
  return false;
 } else {
  return true;
 }
}

Alpha Space Validation in JS

Enter text file allow allphabi & space only
function alpha_space_validation(arg){
 var valReg = /^[A-Za-z ]+$/;
 if(valReg.test( arg ) ) {
  return false;
 } else {
  return true;
 }
}

Email Validation - Form field Validate Email Address

alert(email_validation("asasas"))
function email_validation(arg){
 var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
 if( !emailReg.test( arg ) ) {
  return false;
 } else {
  return true;
 }
}

PHP number format 4 digits [duplicate]

Method I

echo str_pad( "3", 4, "0", STR_PAD_LEFT );
Input $s_number = "3"; Output: 0003

Method II

$s_number = '12';
printf("%04d", $s_number);
Input $s_number = "12"; Output: 0012

Tuesday, 24 June 2014

How to get Enum Values in Mysql?


function get_enum($table,$clname){
  $Query="SHOW COLUMNS FROM `$table` LIKE '$clname'";
  $result = $this->db->query($Query) or die("Get Enum value Query");
  if($result){
    $row = mysql_fetch_array( $result , MYSQL_NUM );
    $regex = "/'(.*?)'/";
    preg_match_all( $regex , $row[1], $enum_array );
    $enum_fields = $enum_array[1];
    return $enum_fields;
  }
  return false;
}

Feet/Inches to Meters Converter & Lbs to Kgs Converter

 <!DOCTYPE html> <html lang="en"> <head>   <meta charset="UTF-8" />   <title>Feet/Inches ⇄...