PHP Archive

Day 22: Login and Logout Functionality With OOPs.

This article is about login and logout functionality with OOPs. There are 4 files used in this script: 1. adminCls.php Class to define member variable and functions related to Admin. 2. index.php is basically a login form, contains html and object of admin class. 3. dashboard.php it’s a secure page and available after successful login.

Day 21: login and logout functionality in PHP

Today you will see how we can use session for security purpose. In below example I have created “tbl_admin” table to store username and password inside mydb database. Below are the scripts to create table and insert record in it. create table tbl_admin (id int primary key, username varchar(45), password varchar(45)) insert into `tbl_admin` (id,username,password)

Day 20: Session in PHP

Session is a way to make data accessible on various pages of the website. Session stores on server and secure then the cookies. Sessions are also used to store individual user data against a unique SessionId and SessionId can be used to share user information between pages requested. In session variable we can store string

Day 19: Cookies in PHP

Cookie is used to store information of a web page. It’s often used to identify user by embedding small file on the user’s computer. When same computer requests a page with a browser, it will send the cookie too. There are 2 types of cookies: Temporary cookies: saved in browser’s memory. Erased when browser closed.

Day 18: Php Oops With MySql (Update and Delete Records)

Continue to the day 17, now we are going to edit, update and delete records with OOPS Program 52: edit, update and delete code in “db1.php” <?php class emp { var $con = “”; var $id; var $name; var $salary; var $city; function __construct() { $this->con = mysql_connect(‘localhost’,’root’,”); mysql_select_db(‘mydb’,$this->con); } function display() { $query =

Day 17: Database Handling With Oops

In database there are 4 basic functions that we have to perform i.e. Display, Save, Update and Delete. Earlier we have done this without OOPS, now we will do this with OOPS. There are 3 files used in this assignment: db1.php : “emp” class and member functions are defined in this file. display.php : used

Day 16: Working with class, variables and Inheritance

Variables are defined in class with ‘var’ keyword. By default variable declared with ‘var’ keyword is publicly assessed, you can also use public $variable instead of var $variable. To access the variables declared in class, we have to use $this keyword. Like shown in blow example. Program 45: Define and access variables in class <?php

Day 15: Object Oriented Programming in PHP

Introduction to OOPS Php5 released in 2004 with OOP features like in C# and java. It was the big change in PHP and now we can code with classes and objects in PHP. In next few days, I will guide you how to work with OOP in PHP. let’s take a look terms related to

Day 14: Submit form without submit button

Sometime it’s require to submit the form on server without submit button, like on dropdown change. So this can be done with the help of JavaScript. I am taking “tbstudent” table, that we have created on “day12”. Program 41: Submit form through JavaScript <?php $con = mysql_connect(“localhost”,”root”,””); mysql_select_db(“mydb”,$con); if(isset($_REQUEST[‘drpEmp’])) { $selectedId = $_REQUEST[‘drpEmp’]; $query =

Day 13: Form validation client and server side.

Is it better to validate form of our website both client and server side. Both have their own advantages. In client side validation we use JavaScript so it’s faster than the server side validation but sometimes when JavaScript disabled on browser then JavaScript doesn’t work then server side validation will work. Create below mentioned table