How To Build A Simple Php Website Tutorial Guide Step By Step Instructions With Code Example
Posted On Tue May 08, 2007 By hostman In Tutorial And Guides Forums And Topics Discussions For Help Forums
hi, i am writing this tutorial for people who are new to PHP and want to create websites with PHP and HTML.
What do you need?
- you need to know what LAMP stands for.. LAMP is, Linux Apache Mysql PHP but since linux is a complicated system thats beyon this tutorial, i am going to show you on Microsoft Windows. so instead of LAMP we will use XAMPP
X = WINDOWS- is the operating system
A = Apache - is the web server
M = Mysql - is the database server
P = PHP - is the scripting language. PHP is a Server Side Scripting language
P = PEARL - Pearl is another server side scripting language
ok, so now that you know what LAMP and XAMPP are, how do you get it.
option 1 - install it on your PC
option 2 - buy it from a web hosting provider (we recommend www.webune.com)
since we are just learning all this, lets get it for free with option 1.
go to apachefriends.org and install XAMPP on your windows PC
after you have installed apachefriends, go to this htdocs folder under C:\xampp\htdocs and create a new folder called wallpaperama
we are going to save all our files in the wallpaperama folder for this tutorial
if you are using a windows computer like windows XP or windows 7, open a blank notepad.
lets create a simple hello world file, in a blank notepad, enter this code:
<?php echo 'hello world'; ?>
now save it as index.php in the wallpaperama folder
now open your browser and go to this url: http://localhost/wallpaperama/index.php
YOU SHOULD SEE THE OUTPUT: hello world
now you can use this code also for the same output:
<?php echo "hello world"; ?>
notice that i use the single quotes and the double quotes, what is the difference?
lets say i want this to be the output: Wallpaperama's wallpaper or "Wallpaperama wallpaper"
this is how i would parse it:
<?php echo '"Wallpaperama wallpaper"'; ?>
<?php echo "Wallpaperama's wallpaper"; ?>
do you see the difference, i would get errors if i did like this:
<?php echo 'Wallpaperama's wallpaper'; ?>
if you only want to use single quotes, you will have to escape the inner single quote like this:
<?php echo 'Wallpaperama\'s wallpaper'; ?>
you can also use the print() function instead of echo. i just like the echo because is easier for me. but if you want to use the print() function you can use it like this:
<?php print('Wallpaperama wallpaper'); ?>
you can combine HTML and PHP together to create webpages, for example, lets say i want to show the date using HTML and PHP:
<h1>Today's Date is: <?php echo date('M,D,Y'); ?></h1>
now that you can start getting creative, here is an example of a complete page: just copy and paste this code into index.php
now copy and past the following code into an empty notepad document:
now save this file as index.php then open it with your browser and watch it in action.
so if you wanted to create a php website huh!, well creating php websites are simple if you have the right tools.
there are some great tools you can get to make php websites. such as zend studio or dreamweaver, but those programs are expensive. if you can't afford these software applications your best bet is to programm your pages with a simple text editor like notepad. however, creating php files with notepad will require you to know more about html and php and will have to write more.
once you are ready to create a public website, first, step is to make sure you have php on your website. if you don't have php, you can go to Webune.com and sign up for php hosting. they have very good service.
UPDATE: some of you have replied that this doesnt work. i have followed these steps and recorded a video that this code does work:
UPDATE: also, did you know you can use short tags. if you try this code in your server and it doesnt work, its because the configuration in PHP is not setup for short tags. but if you want to use short tags, you can use something like this:
<?="this is an example of using short tags";?>
you should always use <?php tags because if you chose to move your scripts to another server, they will always work.
What do you need?
- you need to know what LAMP stands for.. LAMP is, Linux Apache Mysql PHP but since linux is a complicated system thats beyon this tutorial, i am going to show you on Microsoft Windows. so instead of LAMP we will use XAMPP
X = WINDOWS- is the operating system
A = Apache - is the web server
M = Mysql - is the database server
P = PHP - is the scripting language. PHP is a Server Side Scripting language
P = PEARL - Pearl is another server side scripting language
ok, so now that you know what LAMP and XAMPP are, how do you get it.
option 1 - install it on your PC
option 2 - buy it from a web hosting provider (we recommend www.webune.com)
since we are just learning all this, lets get it for free with option 1.
go to apachefriends.org and install XAMPP on your windows PC
after you have installed apachefriends, go to this htdocs folder under C:\xampp\htdocs and create a new folder called wallpaperama
we are going to save all our files in the wallpaperama folder for this tutorial
if you are using a windows computer like windows XP or windows 7, open a blank notepad.
lets create a simple hello world file, in a blank notepad, enter this code:
<?php echo 'hello world'; ?>
now save it as index.php in the wallpaperama folder
now open your browser and go to this url: http://localhost/wallpaperama/index.php
YOU SHOULD SEE THE OUTPUT: hello world
now you can use this code also for the same output:
<?php echo "hello world"; ?>
notice that i use the single quotes and the double quotes, what is the difference?
lets say i want this to be the output: Wallpaperama's wallpaper or "Wallpaperama wallpaper"
this is how i would parse it:
<?php echo '"Wallpaperama wallpaper"'; ?>
<?php echo "Wallpaperama's wallpaper"; ?>
do you see the difference, i would get errors if i did like this:
<?php echo 'Wallpaperama's wallpaper'; ?>
if you only want to use single quotes, you will have to escape the inner single quote like this:
<?php echo 'Wallpaperama\'s wallpaper'; ?>
you can also use the print() function instead of echo. i just like the echo because is easier for me. but if you want to use the print() function you can use it like this:
<?php print('Wallpaperama wallpaper'); ?>
you can combine HTML and PHP together to create webpages, for example, lets say i want to show the date using HTML and PHP:
<h1>Today's Date is: <?php echo date('M,D,Y'); ?></h1>
now that you can start getting creative, here is an example of a complete page: just copy and paste this code into index.php
now copy and past the following code into an empty notepad document:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Simple php tutorial by wallpaperama</title>
</head>
<body>
<?php
if(isset($_REQUEST['Submit']))
{
echo "<h2>Hello ".$_REQUEST['name']."!</h2><hr>Don't forget to tell your friends about Wallpaperama.com!";
}
else
{
?>
<form name="form1" method="post" action="">
Hi, what is your name
<input type="text" name="name">
<input type="submit" name="Submit" value="Submit">
</form>
<?php
}
?>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Simple php tutorial by wallpaperama</title>
</head>
<body>
<?php
if(isset($_REQUEST['Submit']))
{
echo "<h2>Hello ".$_REQUEST['name']."!</h2><hr>Don't forget to tell your friends about Wallpaperama.com!";
}
else
{
?>
<form name="form1" method="post" action="">
Hi, what is your name
<input type="text" name="name">
<input type="submit" name="Submit" value="Submit">
</form>
<?php
}
?>
</body>
</html>
now save this file as index.php then open it with your browser and watch it in action.
so if you wanted to create a php website huh!, well creating php websites are simple if you have the right tools.
there are some great tools you can get to make php websites. such as zend studio or dreamweaver, but those programs are expensive. if you can't afford these software applications your best bet is to programm your pages with a simple text editor like notepad. however, creating php files with notepad will require you to know more about html and php and will have to write more.
once you are ready to create a public website, first, step is to make sure you have php on your website. if you don't have php, you can go to Webune.com and sign up for php hosting. they have very good service.
UPDATE: some of you have replied that this doesnt work. i have followed these steps and recorded a video that this code does work:
UPDATE: also, did you know you can use short tags. if you try this code in your server and it doesnt work, its because the configuration in PHP is not setup for short tags. but if you want to use short tags, you can use something like this:
<?="this is an example of using short tags";?>
you should always use <?php tags because if you chose to move your scripts to another server, they will always work.
Ganesh Thu May 10, 2012
thanks.. but keep updating more...
prabhakaran Wed Mar 21, 2012
its useful for the beginners....
asfsafas Wed Mar 07, 2012
you u simply make time waste...
Mynt Wed Feb 08, 2012
What a silly tutorial... =.=
David Fri Feb 03, 2012
Worst tutorial ever
mutesi Mon Nov 14, 2011
i have liked the tutorial though don't know alot about php.i was asked to creat a simple php website but am not sure,please need help. thanks
amasdasd Thu Oct 13, 2011
not an website
sankar Wed Sep 07, 2011
dont waste time
pounting Wed Jul 27, 2011
love of it,.s not web
zymon Mon May 23, 2011
Dis is called a website??!
Its just a silly page dude...!!
Its just a silly page dude...!!
alex Wed May 04, 2011
too basic didn't teach me anything
totodo Fri Apr 15, 2011
wtf... are you crazy .. this is it??? Damn... this is crap code.. this is not a site..
Imran Tue Mar 01, 2011
Good example.................
Redalert Tue Feb 15, 2011
<SCRIPT>
document.write( " GuestName ", nice to meet you!!!");
</SCRIPT>
<SCRIPT>
document.write( " GuestName ", nice to meet you!!!");
</SCRIPT>
zdrgzxcb Mon Jan 17, 2011
love u........................
Related Content
Information
Forums »
Tutorial And Guides Forums And Topics Discussions For Help »
How To Build A Simple Php Website Tutorial Guide Step By Step Instructions With Code Example
Tutorial And Guides Forums And Topics Discussions For Help »
How To Build A Simple Php Website Tutorial Guide Step By Step Instructions With Code Example
Title: How To Build A Simple Php Website Tutorial Guide Step By Step Instructions With Code Example
Description: this is a short tutorial that will show you how you can create web pages using PHP and html for dynamic pages
Tags: php ,computer ,programming ,script ,php
Info: This Post Has Been Viewed 0 Times Since
Date: Tue May 08, 2007
Author hostman Received 26 Replies #1414
Date: Tue May 08, 2007
Author hostman Received 26 Replies #1414
Share
URL: 

Embed: 

To embed this topic, just copy the code from the "Embed" box. Once you've copied the code, just paste it into your website or blog to embed it
BBCODE:: 

BBCODE is use on forums. You can put this code on all your BBCODE enabled forums like PhpBB, vBulletin® and others. Just Copy and Paste this code on your Posts and Replies on your forums
wallpaperama | Wallpapers | Forums | Terms Of Service
copyright © 2013 wallpaperama - All Rights Reserved - Last Updated Mon May 06, 2013 (-8 GMT)
Powered by: Webune Forums V5
copyright © 2013 wallpaperama - All Rights Reserved - Last Updated Mon May 06, 2013 (-8 GMT)
Powered by: Webune Forums V5