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
1. 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/”
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.
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’);
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_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”);
<input type=”text” name=”fname”>
<input type=”submit” value=”submit”>
$name=mysql_query(“SELECT FullName FROM User where UserID=’$user’”);
echo ‘Could not connect!’;
echo “Welcome “. $row['FullName'];
10. Now goto your XAMPP folder >> htdocs >> Create a new folder ”my-php” and Paste the Index.php file.
Hope you have Understood it, if you have any difficulty you can comment below.