Friday 30 September 2011

Insert Form Data Using Php Mysql

Step 1 : Create Html Form
First Name
Last Name
Date Of Birth
Gender checked="checked" /> Male checked="checked" /> Female
Email Id "/>
Password
Confirm Password
In the above code all the field have a unique "name" and "id" is same in one field but that differ one field one to an other. First step in PHP code to connect with mysql data base.
<?php
 
//Database Information

$dbhost = "localhost";
$dbname = "priyanka";
$dbuser = "root";
$dbpass = "";

//Connect to database

mysql_connect ($dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());
?>
Above code connect the databse priyanka . Now to check submit button. If submit button is click its return the value . Php code to check "is button is click ".
 <?php if(isset($_POST['submit'])){     /*submit is the name of submit button " For example : if submit button name is xyz then we do $_POST[' xyz']    "      */
  
Action code is goes here 

} ?>

form method is post therefore : how we store values in php variables.
$fname = $_POST['fname'];  
  $lname  = $_POST['lname'];
 $date= $_POST['date'];
  $month= $_POST['month'];
 $year= $_POST['year']; 
  $dob = $date ."-" . $month ."-" . $year ;
  $gender = $_POST['gender'];
  $email_id= $_POST['email_id'];
   $pass= $_POST['pass'];
	 $c_pass= $_POST['c_pass'];
	 $datetime = date("m/d/y G.i:s", time());
How to use PHP insert Query :

$query = "INSERT INTO `priyanka`.`users` (`id`, `fname`, `lname`, `dbirth`, `gender`, `email_id`, `pass`, `r_date`) VALUES ('', '$fname', '$lname','$dob','$gender','$email_id','$pass','$datetime')";
	 
	$done = mysql_query($query) or die(mysql_error());
	 if($done) {
	
	 $id1= mysql_insert_id();
		$url = "thankyou.php?id=" . $id1 . ""; 
		 header("Location: " . $url); 
File contain : index.php style.css thankyou.php user.sql import this file in database download

Tuesday 27 September 2011

How to start with Php

There are following steps requirements working with Php .

Step 1 :   Download xampp. (Click here )


what is xampp
XAMPP ( or ) is a free and open source cross-platform web server package, consisting mainly of the Apache HTTP Server, MySQL database, and interpreters for scripts written in the PHP and Perl programming languages..

After Installation Step.
 2A. http://localhost/xampp/   (Link for creating mysql databases)



2B. Go to installation Xampp folder :


                        I was install xampp in c drive . Then i go to c / xammp /htdocs folder and create folder to run my website . For example my folder name is xyz . To run this website i want to go http://localhost/xyz
when i open the url first index.php file is run .



Create a file name index.php and paste the following code.
 <?php echo "This is my first web page using php";
 ?>

Run browser http://localhost/xyz


Download  php code editor from

In next post we learn to create mysql data base and how we connect using php code.



Monday 26 September 2011

PHP's Place in the Web World

PHP is a programming language that's used mostly for building web sites. Instead of a PHP program running on a desktop computer for the use of one person, it typically runs on a web server and is accessed by lots of people using web browsers on their own computers. This section explains how PHP fits into the interaction between a web browser and a web server.

When you sit down at your computer and pull up a web page using a browser such as Internet Explorer or Mozilla, you cause a little conversation to happen over the Internet between your computer and another computer. This conversation and how it makes a web page appear on your screen is illustrated in Figure 1-1.


Here's what's happening in the numbered steps of the diagram:
  1. You type www.example.com/catalog.html into the location bar of Internet Explorer.
  2. Internet Explorer sends a message over the Internet to the computer named www.example.com asking for the /catalog.html page.
  3. Apache, a program running on the www.example.com computer, gets the message and reads the catalog.html file from the disk drive.
  4. Apache sends the contents of the file back to your computer over the Internet as a response to Internet Explorer's request.
  5. Internet Explorer displays the page on the screen, following the instructions of the HTML tags in the page.

Every time a browser asks for http://www.example.com/catalog.html, the web server sends back the contents of the same catalog.html file. The only time the response from the web server changes is if someone edits the file on the server.
Here's what's happening in the numbered steps of the PHP-enabled conversation:
  1. You type www.example.com/catalog/yak.php into the location bar of Internet Explorer.
  2. Internet Explorer sends a message over the Internet to the computer named www.example.com asking for the /catalog/yak.php page.
  3. Apache, a program running on the www.example.com computer, gets the message and asks the PHP interpreter, another program running on the www.example.com computer, "What does /catalog/yak.php look like?"
  4. The PHP interpreter reads the file /usr/local/www/catalog/yak.php from the disk drive.
  5. The PHP interpreter runs the commands in yak.php, possibly exchanging data with a database program such as MySQL.
  6. The PHP interpreter takes the yak.php program output and sends it back to Apache as an answer to "What does /catalog/yak.php look like?"
  7. Apache sends the page contents it got from the PHP interpreter back to your computer over the Internet in response to Internet Explorer's request.
  8. Internet Explorer displays the page on the screen, following the instructions of the HTML tags in the page.



PHP is called a server-side language because, as Figure 1-2 illustrates, it runs on a web server. Languages and technologies such as JavaScript and Flash, in contrast, are called client-side because they run on a web client (like a desktop PC). The instructions in a PHP program cause the PHP interpreter on a web server to output a web page. The instructions in a JavaScript program cause Internet Explorer, while running on your desktop PC, to do something such as pop up a new window. Once the web server has sent the generated web page to the client (Step 7 in the Figure 1-2), PHP is out of the picture. If the page content contains some JavaScript, then that JavaScript runs on the client but is totally disconnected from the PHP program that generated the page.

How to install drupal on local server


Drupal is a free software package that allows you to easily organize, manage and publish your content, with an endless variety of customization. Use Drupal to build everything from personal blogs to enterprise applications. Thousands of add-on modules and designs let you build any site you can imagine. Drupal is free, flexible, robust and constantly being improved by hundreds of thousands of passionate people from all over the world.