To create a dynamic web page, we will have to set up a local server on our local computer. Using a server software like Apache, it will act as a local web server. The local server will then be able to execute PHP and generate HTML web pages for the web browser.

READ MORE :- Web Development Utilities for Windows

WEB-DESIGN1. Download and install the latest version of XAMPP.

2. Now Click start, go to Programs >> XAMPP >> Start XAMPP Server.

3. Open up your browser and type “http://localhost” to check weather your Local server is working.

4. XAMPP comes with inbuilt MySql database called phpMyAdmin, Open up your browser and type “http://localhost/phpmyadmin/”

mysql-database5.  Type ” TestDB ” in create new database and press GO.

6. Now create Table on database Name :-  “User” and Number of fields:- “2” and press GO.database-table

7. This will create two field one for “UserID” and other “FullName”. Define datatype as INT for UserID and VarChar for the FullName, Length/Values 255 for Both field. Set Index as Primary Key for UserID. mysql-database-config

8.  Now open up the Run Query Window, Just Copy paste the below code in SQL query box.

INSERT INTO USER VALUES (1, ‘tatya’);

INSERT INTO USER VALUES (2, ‘nilkanth’);

INSERT INTO USER VALUES (3, ‘satish’);

sql-query

 

Now click on “Run Query” to execute the SQL statements. Now you have successfully created you Database Part, Now comes connecting your PHP page to database.

9. Now open your Notepad or any text editor such as notepad ++ and paste the below code and save the page as index.php

<?php $mysql_hostname = “localhost”;
$mysql_username = “root”;
$mysql_password =””;
$mysql_database = “TestDB”;
$conn = mysql_connect($mysql_hostname, $mysql_username, $mysql_password) or die(“Oops some thing went wrong”);
mysql_select_db($mysql_database, $conn) or die(“Oops some thing went wrong”);
?>
<html>
<head>
<title>Hello PHP</title>
</head>
<body>
<input type=”text” name=”fname”>
<input type=”submit” value=”submit”>
<?php $user=$_GET[“uid”];
$name=mysql_query(“SELECT FullName FROM User where UserID=’$user'”);
if(!$name){
echo ‘Could not connect!’;
}
else
{
$row=mysql_fetch_array($name);
echo “Welcome “. $row[‘FullName’];
}mysql_close();

?>
</body>
</html>

10. Now goto your XAMPP folder >> htdocs >> Create a new folder  “my-php” and Paste the Index.php file.

11. Now open browser type “http://localhost/my-php/”  and type “http://localhost/my-php/index.php?uid=1.”tatya-webpage-php

Hope you have Understood it, if you have any difficulty you can comment below.

3 Comments

  1. Pingback: PHP GET and POST example

Write A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.