PHP step by step tutorials Archive
We have done database connectivity in Day 9, now we will manipulate data in database (i.e. insert, edit, update and delete) with PHP. To manipulate the data I have created more than 1 PHP files, So take a separate folder (I am taking Day11) to put all those below mentioned files. Note : In this
Note : In this assignment, I am taking the same database (mydb) that we was created in Day9, but create below new tables for this assignment and add some records in all three table i.e. tbcity, tbcourse and tbstudent. create table tbcity (id int primary key auto_increment, name varchar(50)) create table tbcourse(id int primary key
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
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 =
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
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
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
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 =
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.
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