How To Create Dynamic Website Page URLs With PHP Script


How To Create Dynamic Website Page URLs With PHP Script. The advantage of creating a php website is that we can create a php page becomes dynamic, in which the content and appearance of the website page can be changed automatically without the need to make changes to the html code of the page. Only by creating a special page that can call a query of the database server or through a request function, the page is able to display the data corresponding to the query.
How To Create Dynamic Website Page URLs With PHP Script How To Create Dynamic Website Page URLs With PHP ScriptTo create a dynamic website page, don’t be difficult. There are 2 ways, the first is by using the request function or using the database website hosting. For this tutorial, we will discuss the easiest way is to create a dynamic website page with the request function.

How To Create Dynamic Website Page URLs With PHP Script

Ho To Create Dynamic URL
If we want to create a dynamic web page, then we have to create a dynamic url that will create a parameter query contains a variable string. For example, see the following dynamic url:
How To Create Dynamic Website Page URLs With PHP Script How To Create Dynamic Website Page URLs With PHP ScriptExplanation:
1. Protocol
2. Subdomain
3. Domain Name
4. Domain Extention
5. Directory Path
6. Page / File Name
7. Query Parameter
Explanation of numbers one to five, of course you already understand well. For number 6 that page / file name is the name of the file that will be made into a dynamic. When there is any demand different then the contents of the page will change.

Distinguishing between static url and dynamic url is the url dynamic always ends with a query parameter. Where the query parameter are variable and query,
for the example above, the variable is query and the query is web+design.

Creating a dynamic url is not difficult. In the query parameters, you simply specify the name of the variable permintaan and when there are more than one variable and then add & as a connector between the variables in the dynamic url. For example,

user=admin&[email protected]

When you have made ​​a query parameter, then was put on the file that will be made dynamic by adding ?, behind the file name. So it will be like the following example :

admin.php?user=admin&[email protected]

Step in creating a dynamic url has been successful, I hope this explanation is easy for you to understand.

How To Create Dynamic Web Page
After creating a dynamic url, we have set up a page that will be created to be dynamic. That we need to create a dynamic web page is a php page because the command format in creating dynamic website page would be run through php script. As explained in the second paragraph, in creating dynamic web page will be assisted with the request function. The following simple function to execute the command request of any query parameters:


If the variable request name is user, then you just change variableofquery above with the username. thus produced will be a $ _REQUEST [‘username‘]. This is just an example and can be replaced with whatever you want.

Complete, create a file with the name: dymanic-page-ex.php and contents as follows:

echo $_REQUEST['username'];

Upload this file in localhost server or website hosting, and open it in the browser by making variance request. As example: dymanic-page-ex.php?username=admin or dymanic-page-ex.php?username=author. See the results, the page content will change according to the command in the variable.

Another more complex example is below.
First, save the script below into notepad or adobe dreamweaver. Then save it as dynamic.php :

<title><?php echo $_REQUEST['title']; ?> <?php echo $_REQUEST['name']; ?></title>
<div class="bio">
<h1><?php echo $_REQUEST['title']; ?> <?php echo $_REQUEST['name']; ?></h1>
<img src="<?php echo $_REQUEST['image']; ?>" width="150px" height="200px"/>
<p>Name : <?php echo $_REQUEST['name']; ?><p>
<p>Born : <?php echo $_REQUEST['born']; ?><p>
<p>Country : <?php echo $_REQUEST['country']; ?><p>
<p>Short biography : </p>
<p><?php echo $_REQUEST['desc']; ?><p>

Then, access files by following some query parameters in your web browser :
Dynamic URL 1

dynamic.php?name=Barack Obama&born=August 4, 1961&country=United States&title=Profile of&image= Obama is the 44th and current President of the United States, the first African American to hold the office.In 2004, Obama received national attention during his campaign to represent Illinois in the United States Senate with his victory in the March Democratic Party primary, his keynote address at the Democratic National Convention in July, and his election to the Senate in November. He began his presidential campaign in 2007, and in 2008, after a close primary campaign against Hillary Rodham Clinton, he won sufficient delegates in the Democratic Party primaries to receive the presidential nomination. He then defeated Republican nominee John McCain in the general election, and was inaugurated as president on January 20, 2009. Nine months later, Obama was named the 2009 Nobel Peace Prize laureate. He was re-elected president in November 2012, defeating Republican nominee Mitt Romney, and was sworn in for a second term on January 20, 2013

Dynamic URL 2

dynamic.php?name=Hillary Clinton&born=October 26, 1947&country=United States&title=Profile of&image= Clinton is the junior United States senator from the state of New York, a position that begins on January 3, 2001. She is married to Bill Clinton, President of the United States to-42 and U.S. First Lady for two terms (1993-2001). Previously, she was a lawyer. On January 22, 2009 Hillary Clinton was sworn in as Minister of Foreign Affairs of the United States. She served as Secretary of State until February 1, 2013, and was replaced by John Kerry.

Once you compare, for sure the contents of this two dynamic urls is different. This is done automatically without the need to spend much of our time to edit the html code of the file.

Conclusion, dynamic website page and dynamic url is quite easy and practical to use for building a website. What do you think, to say your opinions in the comments box below.
Thanks for reading How To Create Dynamic Website Page URL with PHP Script