Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,006 members, 7,814,431 topics. Date: Wednesday, 01 May 2024 at 12:49 PM

Tutorial-building Dynamic Websites - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Tutorial-building Dynamic Websites (18012 Views)

Tutorial: Building A Facebook Chat With Jquery/php / Building Dynamic Websites (Harvard College) / Building Dynamic Websites With MySQL And PHP (2) (3) (4)

(1) (2) (3) (4) (5) (6) (Reply) (Go Down)

Tutorial-building Dynamic Websites by Nobody: 6:47am On Nov 05, 2008
I am very impressed reading the website design tutorial started by ncpat, Thats the easiest tutorial i have ever seen.
And i think it wont hurt anyone if i start a tutorial on using server side languages, since PHP seems to have the largest user group especially on this forum

I will be focusing on PHP/MySQL

I can't go through the whole of Nairaland, so i need someone to point me to a similar thread if it exists

else, I will move on

I will try to make it as easy as possible, with snapshots.

(PHP Gurus are welcome to contribute)

[size=14pt]EDITED:[/size]
We will be having a seminar on the 5th of March in Osun State (I chose my root first  tongue )
If you live very close to Osun state and you dig my tutorials, You can reserve a space. Call me on 08029037890.

For my state, I decided it will be N5,000 per participant.

Other states will follow and will range from N15, 000 to N20,000.
Its going to be 100% practical as we  will be building a website for a fictitious school in osun state.
Re: Tutorial-building Dynamic Websites by Nobody: 10:40am On Nov 05, 2008
The end goal of this tutorial will be to create a simple website that will display news content, The news will be posted by the admin and we will be building that too.

First, we will be setting up a web server (a software meant to send pages to the browser), that will help serve pages to our users the same way the internet does

but this time, on our local computer, we wont be using the internet to develop our website because the internet will slow down our development speed as we will need to upload files to the internet every time we make changes

with the local web server, things will be very fast.

Question: Why use a web server (in this case on our local computer), why not just build our site and save it on my system and run it from there?

Reason: we need to use the same protocol used over the internet: The HTTP (Hyper Text Transfer Protocol)
This way, our pages are parsed (processed, executed, run) by the web server before reaching the user.

we have many free HTTP servers but we will be focusing on the Apache HTTP server,
so just like 9ice, let's go there

http://httpd.apache.org/

Images
1. follow that link
2. make sure you download the binary version if you are not a pro
3. you should have something that looks like that

Re: Tutorial-building Dynamic Websites by Nobody: 10:50am On Nov 05, 2008
Next, we need to install the Apache HTTP server we just downloaded

Images
1. double click the software
2. click next, accept any term & conditions you see
3. enter the text as in this pix and install for all users, that way, you dont have to manually start apache server all the time
4. use the typical installation, and install

(you may see a black screen pop up and disappear, just ignore it) then click finish

Re: Tutorial-building Dynamic Websites by Nobody: 11:04am On Nov 05, 2008
If you see the small icon in the image in your system tray

Then congrats, you have successfully installed the Apache HTTP server on your local computer

you should then open your web browser and type http://localhost/

you should see the second image

if you don't see that in your browser, click on the icon on the system tray to start the server
if any of these steps fails, start all over.


NEXT, we will look at how we can run our pages and where we need to store our pages so that all works fine.
see you tomorrow.

Re: Tutorial-building Dynamic Websites by kolexinfos: 8:09pm On Nov 05, 2008
Thanks for ur effort I really appreciate.
I use IIS as web server and i av configured PHP and MySQL on my system but I need a e-book that teaches one to do basicthings step by step so as to pick up all the experience from the scratch.


I also av a small problem here with creating databases from cpanel.I av setup a site using Dreaweaver I av uploaded the pages to my web host but i am not really sure of how to create databases using the cpanel Phpmyadmin so that makes it impossible to connect to the database that would be used for the html forms on my site.

please my email is kolexinfos@yahoo.co.uk if u can help on a personal basis
Re: Tutorial-building Dynamic Websites by webguru(m): 8:37pm On Nov 05, 2008
pls explain how to use apache in deploying web devt projects on a local server ie connecting to apache from other systems
Re: Tutorial-building Dynamic Websites by kehers(m): 9:56pm On Nov 05, 2008
@kolex
Guess u wont b needg an ebook nw as someone is taking his time to explain better. As regards d db, u can only set dat up directly frm ur cpanel and not d cpanel PMA. Go to database in ur CPanel nd select add new. Any db u add will show up when u now open PMA. Note dat ur db name will b prefixed wt ur cpanel username. So make d changes to ur scripts. Dont forget ur username nd pwd too

mysql_connect('localhost', 'username', 'pwd');
mysql_select_db('username_dbname');

@webguru
Do u mean an intranet thing? Dat has to do with networkg. A system wil be set as d server (with d php, mysql, web server nd project installed on it) nd assigned a static IP. All other connected systems (PCs) can den access d app via d IP. eg http://10.10.2.9/NL instead of http://localhost/NL (on hosting machine) or http://NL.com (internet). Dats just a simple flow though. There are other things. In any case, the major work is d networkg part. All systems dat wil access d project must be networked to d server.
Re: Tutorial-building Dynamic Websites by dre101(m): 9:01am On Nov 06, 2008
@Webdezzi, thanks for the good work, I really appreciate it.
Re: Tutorial-building Dynamic Websites by abes(m): 1:15pm On Nov 06, 2008
@webdezzi
can i use WAMP server as it comes with apache, mysql and php in one package?
Re: Tutorial-building Dynamic Websites by Nobody: 1:32pm On Nov 06, 2008
Kehers has answered it all.

@abes

Yes, you can use wamp, in fact i personally use wampserver 2.0 but it will be very bad for newbies to use wamp.
It will make them feel that is all they need to know.

Infact, i should be showing them how to install the files from source but if i try that, we will spend forever building the website as there would be many questions.

Now back to today's class
Re: Tutorial-building Dynamic Websites by dre101(m): 1:57pm On Nov 06, 2008
we are set grin
Re: Tutorial-building Dynamic Websites by kehers(m): 2:08pm On Nov 06, 2008
@abes
I was patiently waiting for webdezzi to conclude talks on installing Apache, mysql and php before I chip in the boundled softwares - softwares that have mysql, php and apache together so that u just install everything at a go. Being honest, Iv never installed the 3 seperately (I actually use AppServ). But then, this is an opportunity to learn how to do it one by one.
You see, those softwares - appserv, wamp, easyphp and co have their disadvantages. For one, they come with settings that the author thinks is best which is not in all cases correct. For example, there are some extensions (think of this as additional functionalities) that I'd love the current php I run locally to come with. Examples are sqLite, ffmpeg-movie, wbxml and memcached. But since I didnt compile PHP myself, these are out.
What am I driving at? When u do things urself, you have better edge.
Re: Tutorial-building Dynamic Websites by uche1(m): 2:54pm On Nov 06, 2008
we are still waiting,
Re: Tutorial-building Dynamic Websites by Nobody: 3:08pm On Nov 06, 2008
NEXT, we will look at how we can run our pages and where we need to store our pages so that all works fine.

If you are not new to computers, you must have noticed that files on your computer always end with an extension
e.g
.txt -Text document, opens with notepad
.jpg -Image document, opens with ms paint or other graphics program
.html -Hypertext markup file, opens with your default web browsers

Now lets focus on .html file,

copy the html code below, open notepad up and paste it in it

<html>
<head>
<title>Building Dynamic Website Tutorial</title>
</head>
<body>
<table width="777" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#333333">
 <tr>
   <td bgcolor="#FFCC66"><h1><br>
    &nbsp; MYFIRSTWEBSITE.COM<br>
     <br>
   </h1></td>
 </tr>
 <tr>
   <td><br><p>&nbsp;
     Please take time to read what i have for you in the news section<br>
     &nbsp; <a href="#"><strong>Click here to get news update</strong></a></p>
   <p>&nbsp;</p>
       <p>&nbsp;</p>
   <p>&nbsp;</p>
   <p>&nbsp;</p>
   <p>&nbsp;</p>
   <p>&nbsp;</p>
   <p>&nbsp;</p>
   <p>&nbsp;</p>
   <p>&nbsp;</p></td>
 </tr>
 <tr>
   <td bgcolor="#666666"><div align="center" style="font-size: 12px; color: #CCCCCC;">HOME | ABOUT | NEWS </div></td>
 </tr>
</table>
</body></html>

now save the file as .html
To save the file as .html, from your notepad, click file >save as
you will see a save as dialog window
where you have filename, type "tutorial.html", plus the double quote
hit save (image 1 below)

Or

where you have the filename, type tutorial.html, without the double quote
set the Save as type: to all files
hit save (image 2 below)

windows is smart enough to know that you want the file in .html format and not .txt
if you end up with an icon like you have in image 3 below, then you have not followed the step properly


make sure you save it on your desktop for now

Re: Tutorial-building Dynamic Websites by Seton(m): 3:32pm On Nov 06, 2008
@Webdezzi,
Thanks for the good work, Remember to add creating forms using PHP
Re: Tutorial-building Dynamic Websites by Nobody: 4:30pm On Nov 06, 2008
@seton, its part of what we will be accomplishing with this tutorial

Next, double click on the file from your desktop and it will open in your default web browser showing
(image 1 below)

if you look at the location of the file from the browser, it says something similar to this

file:///C:/Documents and Settings/Oluwaseun Emmanuel/Desktop/tutorial.html

That is not what we want,

we want to open the file using the HTTP protocol
so we need to put the file in a directory (directory means folder) where our Apache will be able to locate the file.
and serve it using the HTTP protocol (i know that is tautology, but we need it here)

where is that directory?

it is somewhere in your apache installation directory (folder)
Let's go there

open My computer, double click on the Local Disk (Csmiley
from there, open Program Files > Apache Software Foundation > Apache2.2 > htdocs

by default, Apache looks inside htdocs and attempts to serve files inside it,
As far as apache is concerned, if your file is not in that folder
it doesn't exist

he would just say 404 (thats an error code for file not found)

before we relocate our tutorial.html, let us look at the index.html in that directory
when you type http://localhost without specifying the filename

Apache tries to complete the rest for you by look out for an index.html file
if index.html is present, it loads it, if absent, it displays the content of the directory

confirm this by renaming index.html in the htdocs directory to something else, e.g renamed.html

now from your web browser, try http://localhost

and see what happened

This little logic is what you will use to tell apache what your homepage is
for instance, tutorial.html is what we want as our homepage, so we will just rename it to index.html (don't do that yet) and apache will load it once we type http://localhost/

so if we were to be on the web, typing http://www.dealersnest.com will load the index file placed in the folder of that website

Now, for this tutorial
we will be creating a new folder inside the htdocs folder and we will name the folder "tutorial"
then copy the tutorial.html and paste it inside the tutorial folder

Now, you should have the tutorial.html file inside the tutorial folder, and the tutorial folder should be inside the htdocs folder

to access the tutorial.html file, just type, http://localhost/tutorial/tutorial.html
(you should begin to get a picture of what is going on)
make sure you use a forward slash "/" when using localhost to access a file

So lets say we have another website to design, we will create another folder inside the htdocs folder for that website
and access it typing http://localhost/newsite

That helps keep things organized

Re: Tutorial-building Dynamic Websites by Nobody: 5:55pm On Nov 06, 2008
Now, rename the tutorial.html to index.html

so we wont be accessing the file this way anymore  -> http://localhost/tutorial/tutorial.html
 
instead, we will just type this and we are fine  -> http://localhost/tutorial


after typing that, you should end up with a page that says, MYFIRSTWEBSITE.COM

with a link that says, click here to get news update. don't worry, the link has been disabled.


That will be all for today, you can keep playing with this till tomorrow when i will introduce you to a notepad called notepad++, nothing big, we just want to take advantage of the code coloring of that notepad.

That way, its easier to spot out coding mistakes.
Re: Tutorial-building Dynamic Websites by MT: 10:56pm On Nov 06, 2008
@webdezzi

For you to make out time to add values to the life of others, without any form of compensation, you deserve more than a pat at the back. All I can say is "May God Bless You". Thanks we all appreciate your kind gesture
Re: Tutorial-building Dynamic Websites by abes(m): 4:02pm On Nov 07, 2008
Thanks man, your step-by-step method is the best around, keep it up cool cool
Re: Tutorial-building Dynamic Websites by webguru(m): 4:56pm On Nov 07, 2008
@ kehers

thats wot i meant.

The problem wld b the NL part in http://localhost/NL
and ports to use

id love to deploy php for biz apps
Re: Tutorial-building Dynamic Websites by Nobody: 7:57pm On Nov 07, 2008
@webguru

I think it will be better if you don't confused port with IP,
they are separate terms, and you should not be talking about port here

and i forgot to mention that typing http://127.0.0.1 will also point you to http://localhost
Re: Tutorial-building Dynamic Websites by Nobody: 9:57pm On Nov 07, 2008
now, lets go grab our notepad from sourceforge

http://sourceforge.net/project/showfiles.php?group_id=95717&package_id=102072

I googled for "notepad++ download" and got that link

Image 1- click that link to download the notepad++
Image 2 - You should end up with that chameleon icon

I expect you to be a pro at installing softwares by now, as we have previously installed Apache
so go ahead and install the notepad with the default setting (default mean, the ways it is, without changing any settings)

Image 3 - That the notepad.

The good thing about this notepad is that he understands most programming languages, all you have to do is to tell the notepad what language you intend to code in
and the notepad will start coloring your codes in that language

I am not very comfortable with the default color settings of this notepad (for PHP) so we will be modifying the colors.

I will show you how

Re: Tutorial-building Dynamic Websites by Nobody: 10:22pm On Nov 07, 2008
well, i changed my mind, you can go ahead and set the colors to your preferred color, i will go ahead and reset mine

to reset colors,
follow image 1

Image 2 - you select that language, then change colors for each item under style
(newbies may find it hard to do this, dont worry, leave it as it is and exit the configurator, you will catch up later)

image 3 - thats where you need to select the language, in our case, it is PHP

and we are on our way to programming.


But before then, we need to understand the basics of what we are about to do.

Re: Tutorial-building Dynamic Websites by Nobody: 11:24pm On Nov 07, 2008
GOAL OF THIS TUTORIAL: create a page that will display news, the news will be posted by the admin.

Before we start, we need to understand that, we need a storage system to help us store the news so that the news will always be available to whoever requests for it.

Now, look at this storage system as your wallet,

everytime you need money, you reach for it
everytime we request for the news page, our php script reaches for the storage (called database, programmers prefer to call it DB)

Now, we have installed Apache that will serve our pages,
we need to install a "storage system" (Database) in this case, it is MySQL Database

Note that the script or code that we will be writing is also a software application, because we have it on the web, it is call a web application

so we need a web application language to help us handle the programming part
unfortunately, Apache does not come with the ability to do this.

we will need to install php application sever- this is php itself
once you install it, this PHP application server will continue to run on the Apache HTTP server

pages ending with .php will then be parsed by the PHP application server, the result is passed over to the Apache HTTP server and sent to the user who requested it.

Look at it this way,
Apache is the Landlord
PHP is the tenant

everytime someone comes around asking for a php page from Apache,
Apache consults his tenant, who in turn tells Apache how to treat the visitor

Look at this again

someone came asking for .html page, even though the PHP server is running, He does not have to interfere
and that alone makes .html pages load faster than php pages (although the difference is negligible)
because, the landlord can attend to the visitor without having to consult his tenant

bottomline, if you have a page that has no php code in it, always name such page .html


Now let us go install PHP from php.net
and MySQL from mysql.com

visit those sites and download what they have.
below are the final links

mysql - http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-essential-5.0.67-win32.msi/from/http://mysql.skynet.be/
php - http://www.php.net/get/php-5.2.6-win32-installer.msi/from/ar.php.net/mirror

they are fairly large files, download them tomorrow, we will be installing them.
Re: Tutorial-building Dynamic Websites by RuuDie(m): 1:32am On Nov 08, 2008
Nice one webdezzi. . . . . you're a GEM grin


Pls i have a couple of questions:

1. can i use this PHP/MySQL/Apache combo on a window XP proffessional system that already has IIS running?
2. can i use this PHP/MySQL/Apache combo on a window XP Home Edition system?


Thanks for the education man!
Re: Tutorial-building Dynamic Websites by kehers(m): 6:27am On Nov 08, 2008
@ruudie
Ds softwares av different versns for d various OS around - b it windows, linux, wateva. Just look around d download page of d respective site. D windows versn which webdezzi posted its links (bet he is assuming we all run on windows) wil work for ur OS - XP whateva or Vista whateva.
And back to ur nö 1 questn, do u mean running apache and IIS? Iv not tried dat out before but to be on d safe side, I think u may have to turn off one to use d other esp if the two listens to d same port.
Re: Tutorial-building Dynamic Websites by Nobody: 1:11pm On Nov 09, 2008
@ruudie

yes, but you have to stop one for the other

So if you want to write asp, you might want to stop apache HTTP, from the system tray.
please note that if you prefer IIS, then forget about Apache, so we will be installing PHP on IIS

and yes again, you can use the 3 on windows xp home edition

@kehers,
yes, i assume everyone is on windows, if you are on linux, please go ahead and figure things out (you are definitely not new to installations)

Sorry, tutorials continue tomorrow
Re: Tutorial-building Dynamic Websites by Seton(m): 11:35am On Nov 10, 2008
@Webdezzi,

You have challenged me a lot to think about starting on what will impact the life of so many persons. Keep up the good work.

Now it is really true that, the best way to help ourselves is to help other people solve their problems
Re: Tutorial-building Dynamic Websites by Nobody: 11:44am On Nov 12, 2008
Lets install our PHP, (it really does not matter which one you install first, mysql or php)

However, you will need to install a web server before php, because without the web server, php can not work
see for yourself when installing php

It will ask what web server you want to use,
so for those asking if you can install php on iis, look at the picture and see where you have to do that.

Note: you will need to stop all running webservers for installation to be successful

For mysql, you can install it even before installing a webserver, thats because it is a service that can run independently

If you have problems with installing these guys, make a post and you will get help.

Re: Tutorial-building Dynamic Websites by Nobody: 11:48am On Nov 12, 2008
look at the last picture above, compare it to this one i just posted,

you will be enabling EXTENSIONS and EXTRAS, so that you don't have to go looking for them later on.
and the manual, should come with it too if you enable them

Re: Tutorial-building Dynamic Websites by Nobody: 9:42pm On Nov 12, 2008
follow the procedures below for MySQL installation.

(1) (2) (3) (4) (5) (6) (Reply)

Facebook Owner Mark Zuckerberg Reacts To President Trump Policy. / Learn The Domain Name Business - See What Sold, See What Just Dropped / Lagos Schools Where Hackers Are Trained

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 73
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.