05 Oct 2014
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 = […]
20 Sep 2014
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 […]
07 Sep 2014
Day 12: Handling Multiple Tables In PHP With MySql Join
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 […]
30 Aug 2014
Day 11: Data Manipulation With PHP
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 […]
23 Aug 2014
Day 10: Include files In PHP
This is one of the strong feature of PHP that we can include content of one PHP or HTML file into another PHP file. With this feature we can reduce our codes of line and also avoid repentance of code. This can be done With the help of: include() function require() function include_once() function require_once() […]
17 Aug 2014
Day 9: Database connectivity in PHP
Database is used to store information. In PHP we are using MySql as database server. Below are the steps to use MySql server with PHP: Step 1 : Start MySql from your xampp panel. Step 2 : Open “http://localhost/phpmyadmin/” in browser. Step 3 : Create new database in your localhost server (let’s take database name […]
03 Aug 2014
Day 8: Form Validations in PHP
Form validations are used to filter valid data from form. Below are the examples of form validation with regular expression. These are also called server side validations. Program 29: Required field validation. <?php $msg = “”; if(isset($_REQUEST[‘btnSubmit’])) { $name = trim($_REQUEST[‘txtName’]); $email = trim($_REQUEST[‘txtEmail’]); $mobile = trim($_REQUEST[‘txtMobile’]); $message = trim($_REQUEST[‘txtMessage’]); if($name==””) { $msg = $msg […]
05 Jul 2014
Day 7: Form Handling and Types of errors in PHP
Form is one of the powerful features of PHP. Below is an example of HTML Form: Program 25: Form example with GET method. <?php echo “hello “.$_GET[‘txtName’]; ?> <html> <body> <form> Name: <input type=”text” name=” txtName”> <br> <input type=”submit”> </form> </body> </html> Note: By default form has get method, so $_GET is use in above […]
28 Jun 2014
Day 6: Array and foreach loop
Array can hold more than one value at a time. It’s a organized collection of key-value pairs. By default keys of array starts with 0, whoever we can define our own keys also. Syntax: $Ar = Array(emement1, emement2, emement3,…); Program 21: Define and display indexed array. <?php $ar = Array(30,56,amit,ravi); for($i=0; $i < count($ar); $i++) […]
08 Jun 2014
Day 5: while, for and switch-case
Loop is use to do repetitive work until task has not been completed. 1) Understanding “while” Control Structure while is the simplest type of loop in PHP, statement inside the while loop executes until condition in ture. Syntax: while (condition) { statement here will execute when condition is true. } Program 13: Display series 1-10. […]