disable button on click for a few seconds

05:28:00 1 Comments

<button id="input-sales-btn" class="btn btn-success" onclick="inputBtnClicked('sales');this.disabled=true;
setTimeout(function(){ $('#input-sales-btn').removeAttr('disabled'); }, 15000);">Done
                    </button>

1 comments:

redirect or logout user from a php application very easy

05:28:00 0 Comments

 <?php
$variablephp = $_SESSION['uname'];
?>
    <script>
   
    setInterval(function() {
  // method to be executed;
       
        var variablejs = "<?php echo $variablephp; ?>" ;
alert("variablejs = " + variablejs);
        if(){}
       
}, 5000);
   
    </script>

0 comments:

Create an Android App from a Responsive website Easy.

21:22:00 2 Comments

The below code will help you create a Android app from your responsive website.Please copy this HTML code to the index file of your cordova project and then build the project.Change logo in your cordova project with your respective logos.

<head>
    <title>Home</title>

    <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
    <script type="text/javascript" charset="utf-8">

    // Wait for device API libraries to load
    //
    function onLoad() {
        document.addEventListener("deviceready", onDeviceReady, false);
    }

    // device APIs are available
    //
    function onDeviceReady() {
        // Register the event listener
        document.addEventListener("backbutton", onBackKeyDown, false);
    }

    // Handle the back button
    //
    function onBackKeyDown() {

magic();
    }


function magic (){

    $("#button").click(function(event){    
        //var h = document.getElementById("myIFrame").contentWindow.history;
       
        //h.back();
     
        $("#myIFrame").attr('src', window.history.back());
    });

}

    </script>
  </head>





<script
  src="https://code.jquery.com/jquery-3.1.1.js"
  integrity="sha256-16cdPddA6VdVInumRGo6IbivbERE8p7CQR3HzTBuELA="
  crossorigin="anonymous"></script>
<iframe id="myIFrame" src="http://yourwebsite.com" style="position:fixed; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%; border:none; margin:0; padding:0; overflow:hidden; z-index:999999;" scrolling="yes" frameborder="0" allowTransparency="true"></iframe>

<script>

</script>

2 comments:

Easy MD5 password Encryption Decryption Example using php



Here are the main lines of code the encrypt the password


PART 1 Password Encryption 
//get the password in variable
$password = isset($_GET['password']) ? mysql_real_escape_string($_GET['password']) :  "";

//here n5tZoJDknmUgY6LR21FFr4SAoQK8ACajoO3egV0I2JU4Uu8ihuk20hgm is the hashkey do save it
//encrypt using the below syntax then insert into database

 $password = md5("n5tZoJDknmUgY6LR21FFr4SAoQK8ACajoO3egV0I2JU4Uu8ihuk20hgm".$password."");

==========================================================

Here below is the full code I used

<?php header('Access-Control-Allow-Origin: *'); ?>
<?php header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept'); ?>
<?php header('Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT'); ?>

<?php

//echo "hi there";


include_once('confi.php');
error_reporting(E_ALL);
$name = isset($_GET['name']) ? mysql_real_escape_string($_GET['name']) :  "";
$email = isset($_GET['email']) ? mysql_real_escape_string($_GET['email']) :  "";
$password = isset($_GET['password']) ? mysql_real_escape_string($_GET['password']) :  "";
    $password = md5("n5tZoJDknmUgY6LR21FFr4SAoQK8ACajoO3egV0I2JU4Uu8ihuk20hgm".$password."");
$uid = isset($_GET['uid']) ? mysql_real_escape_string($_GET['uid']) :  "";
    $idshop = isset($_GET['idshop']) ? mysql_real_escape_string($_GET['idshop']) :  "";
    if(!empty($uid)){
        $query = "SELECT * FROM ps_customer WHERE email = '$email' AND id_shop='$idshop'";
        $qur = mysql_query($query);
        $existCount = mysql_num_rows($qur); // count the row nums
if ($existCount == 0) { // evaluate the count
//echo "Proceed";
 
    $securekey = md5(uniqid(rand(), true));
   
     $insertstatement = "INSERT INTO `ps_customer` (`id_customer`, `id_shop_group`, `id_shop`, `id_gender`, `id_default_group`, `id_lang`, `id_risk`, `company`, `siret`, `ape`, `firstname`, `lastname`, `email`, `passwd`, `last_passwd_gen`, `birthday`, `newsletter`, `ip_registration_newsletter`, `newsletter_date_add`, `optin`, `website`, `outstanding_allow_amount`, `show_public_prices`, `max_payment_days`, `secure_key`, `note`, `active`, `is_guest`, `deleted`, `date_add`, `date_upd`) VALUES (NULL, '1', '$idshop', '1', '3', '1', '0', NULL, NULL, NULL, '', '$name', '$email', '$password',NOW(), '2000-01-01', '0', NULL, '0000-00-00 00:00:00', '0', NULL, '0.000000', '0', '0', '$securekey', NULL, '1', '0', '0', NOW(), NOW());";
  //  echo $insertstatement;
    $query123 = mysql_query($insertstatement);
   
   
    $selectquery = "SELECT MAX(id_customer) a FROM `ps_customer`;";
  //  echo "$selectquery";
   
     $query1 = mysql_query($selectquery);
  //  echo"test" ;
    while($row = mysql_fetch_array($query1)) {
       
      $id_customer = $row['a'];
       //  $id_customer1 = int($id_customer) + 1;
    }
   // echo "'.$id_customer.' i am first";
    //$id_customer1 = $id_customer + 1;
   // echo "$id_customer1";

    $insert2 = "INSERT INTO `ps_customer_group` (
`id_customer` ,
`id_group`
)
VALUES (
'$id_customer',  '3'
);";
   
   //echo "$insert2";
    $query123 = mysql_query($insert2);
    $true = "true";
    $result[] = array("status" => $true,"id_customer" => $id_customer);
   $json = $result;

   
}else{
    $false = "false";
//echo "Your login session data already exists in the database.";
    $result[] = array("status" => $false);
   $json = $result;
   
}
}
@mysql_close($conn);
/* Output header */
header('Content-type: application/json');
echo json_encode($json);


//echo "$query i m qwedrdfrd";
//echo "$existCount i m exist";
//echo "$insertstatement";



PART 2 Password Decryption 

Below is an example of login where we select the user from database here MD5 Decryption is used.

<?php
// Include confi.php
include_once('confi.php');
$shopid = isset($_GET['shopid']) ? mysql_real_escape_string($_GET['shopid']) :  "";
$email = isset($_GET['email']) ? mysql_real_escape_string($_GET['email']) :  "";
$passwd1 = isset($_GET['passwd']) ? $_GET['passwd'] :  "";
if(!empty($email)){
        $mysql = "select id_customer,firstname,lastname,passwd,email from ps_customer where email = '".$email."' AND id_shop='".$shopid."'";
       // echo "$mysql";
$qur = mysql_query($mysql);
$result =array();
while($r = mysql_fetch_array($qur)){
extract($r);
            //echo "$r";
$passwd1 = md5("n5tZoJDknmUgY6LR21FFr4SAoQK8ACajoO3egV0I2JU4Uu8ihuk20hgm".$passwd1."");

if($passwd1 ==$passwd){

 $result[] = array("id_customer" => $id_customer, "firstname" => $price,"lastname" => $lastname, 'passwd' => $passwd, 'email' => $email);
 }else{}}
$json = $result;
}else{
$json = array("status" => 0, "msg" => "User ID not define");
}
@mysql_close($conn);

/* Output header */
header('Content-type: application/json');
echo json_encode($json);


1 comments: