Session

The session is use to store user information for use later.Normally the information that store are username and password.The information is temporary and will be deleted when user close the browser or left the website

Example of session:

session_start(); // start up your PHP session!

$_SESSION[username]=$_POST[username]; //stored the username session from the form

Use isset to check the session:

if (isset($_SESSION[username])){
header ('Location: home.php');
}


Destroy session:

session_destroy();

Create array

An array can store multiple values in one variable..

Below is the example of array in php

$days = array("sun","mon","tue","wed","thur","fri","sat"); //array declaration

we also can declare an array like this

$days[1] = "sun";
$days[2] = "mon";
$days[3] = "tue";

the following example is to print the value in array

echo "Today is:".days[1];

the output is
sun

encrypt text

we use md5 method in php to ecript text.

$text = "something";
$enc_text= md5($text);

echo "ecript text": $enc_text;

login

session_start();

include db_conn.php";

if (isset($_POST['Login'])){
$sql_login = "select * from login where no_id = '$_POST[no_id]' and pass = '$_POST[password]'";
$res_login = mysql_query($sql_login);
$row_login = mysql_fetch_array($res_login);
}
if ($row_login) {
$_SESSION['no_ic'] = $_POST['no_ic'];
header("location:home.php");
exit();
}
else{
echo "No user found";
}

simple php tutorial

for loop

for loop is to run your script in many times

example

for ($i=0;$i<10;$i++){
echo $i;

}

//the output will be like this
0123456789

if else condition

if ($today =="sunday"){
echo "enjoy your holiday";
}
else {
echo "have a nice day";
}

Create a Table

we use CREATE TABLE statement to create table in mysql

//sql statement to create table
$sql="CREATE TABLE (column_name1 data_type,
column_name2 data_type,
column_name3 data_type) ";

example:

$con = mysql_connect("localhost","root","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

// Create database
if (mysql_query("CREATE DATABASE my_db",$con))
{
echo "Database created";
}
else
{
echo "Error creating database: " . mysql_error();
}

// Create table
mysql_select_db("my_db", $con);
$sql = "CREATE TABLE customers
(
Name varchar(15),
designation varchar(15),
Age int
)";

// Execute query
mysql_query($sql,$con);

?>

Create the database

To create the database, we need to use mysql_query function and CREATE DATABASE statetment

$conn = mysql_connect("localhost","root","root");
if (!$conn)
{
die('Could not connect: ' . mysql_error());
}

if (mysql_query("CREATE DATABASE my_db",$conn))
{
echo "Database created";
}
else
{
echo "Error creating database: " . mysql_error();
}

?>

connect php to mysql

Normally the database that used in PHP langguange is MYSQL..MYSQL is also the open-source software.Below is the example of php-mysql connection

mysql_connect(servername,username,password);

$conn = mysql_connect("localhost","root","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

?>

php variable

A variable is an area of memory which is set aside to store information , this is assigned an identifier by the programmer . You can recognise variables in PHP because they are prefixed with the dollar ( $ ) sign . To assign a variable you use the assignment operator ( = ) . Here is an example of this.

$name = "myname";
$age = 45;

PHP

PHP is a scripting language designed for web development and can be embedded into HTML. PHP language runs on a web server, the code of PHP acts as the input and output is the creation of the web pages. The language is also used for command-line scripting and client-side GUI applications. PHP has been deployed on many web servers, operating systems and platforms. It is also useful with many database management systems. The complete source code is available to the users for free. The users can build; customize language according to their requirements.

PHP has been created by Rasmus Lerdorf in the year1995. PHP’s main implementation is now produced by The PHP Group and it is released under the PHP License. According to the Free Software Foundation it is considered as free software.

PHP was originally designed to create only dynamic web pages. It is a server-based script and is similar to other server-based script languages such as Microsoft's ASP.NET system, Sun Microsystems' JavaServer Pages and mod_perl. PHP’s main framework provides building blocks and design structure to promote rapid application development (RAD). Some of the frame works include CakePHP, PRADO, Symfony and Zend Framework.

PHP acts as a filter, taking input from a file or stream containing text and instructions the outputs for another stream of data. The most common form of the output is HTML. The most popular architecture is the LAMP architecture for deploying web applications. In PHP the P is refer to Python or Perl and it is used as bundle alongside with Linux, Apache and MySQL.

PHP interface also has Extensions with a number of systems such as IRC, and Windows API. PHP extensions are used in creating Macromedia Flash movies. In the Version 3, PHP has integrated object oriented features and Version 5 has limited functionalities. Now PHP has robust object capabilities such as interface, exceptions, destruction and abstractions which are a great help in the development of a website.

PHP has wide-spread popularity because of the version 4. It is considered as one of the top languages used for server-based scripting. The language is easy to learn. PHP has many arrays and variables which can hold any type of object, where the variables need not be declared, and the syntax is remarkably simple.

If you are looking for PHP Web Development and looking for a company who has the expertise in PHP technology working with latest PHP and My SQL version contact IT Chimes. IT Chimes is one of the few companies in India who has the needed knowledge, expertise and the resources to provide complex solution in PHP, Joomla, Drupal, Zen Cart, Zend Framework, OS Commerce and more.