After a Database and a Table have been created, we can start adding data in them. //Insertions method store in function for get / post if(isset($_GET[‘memberpost’])) { session_start(); include(‘function/db.php’); global $conn; $sl1 = $_GET[‘l1’]; $sl2 = $_GET[‘l2’]; $sl3 = $_GET[‘l3’]; $sl4 = $_GET[‘l4’]; $sl15 = $_SESSION[‘session’]; date_default_timezone_set(“Asia/Kolkata”); $sl6 = date(‘Y-m-d’); $stmt = $conn->prepare(“INSERT INTO tab(l1,Continue reading “PHP – Insert Data Into MySQL Using Parameters”
Category Archives: PHP
Secure Way for Protecting Query-string Keys & Values
Here We are using Triple DES Method $key = “password”; // Try to Generate 128- 256 bit key . <a href=”/index.php?i=<?php echo encryptText($user_id,$key); ?>”>Click here</a> <?php function encryptText($plainText, $key) { $keyData = “xA2x15x37x08xCAx62xC1xD2” . “xF7xF1x93xDFxD2x15x4Fx79x06” . “x67x7Ax82x94x16x32x95”; $padded = pkcs5_pad($plainText, mcrypt_get_block_size(“tripledes”, “cbc”)); $encText = mcrypt_encrypt(“tripledes”, $keyData, $padded, “cbc”, $key); return base64_encode($encText); } ?> Your Link Will beContinue reading “Secure Way for Protecting Query-string Keys & Values”
Triple DES Encryption and Decryption in PHP
You have to generate a Key and Save for further Decryption. <form id=”form3″ name=”form3″ method=”post” action=””> enter text <input name=”data2″ type=”text” /> <input type=”submit” name=”Submit2″ value=”Encript” /> <input type=”submit” name=”Submit3″ value=”Decript” /> </form> <?php if(!isset($_POST[‘Submit2’])) { }else { $buffer = $_POST[‘data2’]; $key = “password”; $r1 = encryptText($buffer, $key); echo “Encrypted Value = “.$r1; } if(!isset($_POST[‘Submit3’]))Continue reading “Triple DES Encryption and Decryption in PHP”
Encryption and Decryption – Base 64
Here is the Way to Encode And Decode Data <form id=”form5″ name=”form5″ method=”post” action=””> enter text <input name=”data5″ type=”text” /> <input type=”submit” name=”Submit5″ value=”Encript” /> <input type=”submit” name=”Submit6″ value=”Decript” /> </form> <?php if(!isset($_POST[‘Submit5’])) { }else { $buffer = $_POST[‘data5’]; echo base64_url_encode($buffer); } if(!isset($_POST[‘Submit6’])) { }else { $buffer = $_POST[‘data5’]; echo base64_url_decode($buffer); } echo “<br/>”;Continue reading “Encryption and Decryption – Base 64”
URL Re-Writing in PHP using Query – String
Here is Best Way to Re-Write URL using Query – String [ Dynamically] First You must have to change into your apache httpd file 1- Go to Your apache dirc. and open httpd.conf (C:xamppapacheconfhttpd.conf) 2- Find the line #LoadModule rewrite_module modules/mod_rewrite.so and remove the hash ‘# 3- Find the block within the directory tags as indicated below and change to: <directoryContinue reading “URL Re-Writing in PHP using Query – String”
Get the client IP address in PHP?
Mostly useful in e-commerce website to store products into the cart. <?php function getip() { $ip = $_SERVER[‘REMOTE_ADDR’]; if (!empty($_SERVER[‘HTTP_CLIENT_IP’])) { $ip = $_SERVER[‘HTTP_CLIENT_IP’]; } elseif (!empty($_SERVER[‘HTTP_X_FORWARDED_FOR’])) { $ip = $_SERVER[‘HTTP_X_FORWARDED_FOR’]; } return $ip; } Now We can Print the Ip using – $ip = getip(); echo $ip ; ?>
Generate Unique Id / Key using Your Given Character
The best and simple way to generate an id. <?php function crypto_rand_secure($min, $max) { $range = $max – $min; // define range if ($range < 1) return $min; // not so random… $log = ceil(log($range, 2)); // trim the range into numbers $bytes = (int) ($log / 8) + 1; // length in bytes $bitsContinue reading “Generate Unique Id / Key using Your Given Character”
SQL Injection Cheat Sheet
Basic SQL Injection Tricks admin’ — admin’ # admin’/* ‘ or 1=1– ‘ or 1=1# ‘ or 1=1/* ‘) or ‘1’=’1– ‘) or (‘1’=’1–