Posts

Showing posts from March, 2018

How to Create Database Using Mysql,Mysqli,PDO or using Oops concepts in php?

Image
 Database Using Mysql,Mysqli,PDO or using Oops concepts in php? mysqli could be a additional for the mysql functions, with object-oriented and procedural sorts. it's support for prepared statements. PHP data Objects(PDO) could be a general database construct layer with support for MySQL between several other databases. 1. The mysql functions are practical and use manual escaping. 2. MySQLi is a additional for the mysql functions, with object-oriented and procedural versions. It has support for prepared statements. 3. PDO (PHP Data Objects) is a general database abstraction layer with support for MySQL among many other databases. Database Connection Using Mysql:  <?php $con=mysql_connect("localhost","root","password"); if(!$con) { //die('could not connect:' mysql_error(); } $db=mysql_select_db("dbname",$con); if(!$db) { die("Error in Database Connection"); } ?> Database

Difference between a Session and a Cookie?

Image
A session is a global variable stored on the server side. Each session is assigned a unique id which is used to retrieve a  stored values. Ex-First start session <?php session_start(); $_SESSION["name"]=$_POST["username"]; ?> • Sessions have the volume to store comparatively large data compared to cookies. The session values are automatically deleted when the browser is closed then session is expired. • Session data is stored on the server side, whereas cookies store data in the visitor's browser side. • Sessions are more secure than cookies as it is stored in server. Cookie can be turn off from browser. Ex- Cookie start with Syntax: setcookie(name, value, expire, path, domain);  <?php $xyz=time()-60*60*24*30; //  Sec*Mint*Hours*Day setcookie("Mohit"," Bca 1st Year",$xyz); echo $_COOKIE['Mohit']; print_r($_COOKIE); ?> Session: Session variables stored information about one single user, and