This is the first part of a series of tutorials on building a dynamic site using PHP and MySQL. If anything is unclear at any point in this series, please mention so in the comments and I will try to address it ASAP

1) Setting up and testing MAMP (or WAMP etc.)

Question: Why Do I Need MAMP?

Answer: Unlike HTML (Hypertext Markup Language), which is a markup language, PHP is what is called a server-side scripting language. This means that it talks to the server where your site is hosted and renders before your code / markup ever makes it to your web browser (client). With HTML, you could just open your file straight into a web browser and it would render your HTML correctly, but PHP most be run from a server (with PHP installed) which “hosts” the web page. MAMP makes such a server locally on your computer.

  1. First thing we gotta do to get started with PHP is to download MAMP. Here is a link to the download page (download the free version).
  2. After you have MAMP downloaded – open the MAMP application and turn on the server (it’s the button that says “start servers”).
  3. In your file browser or command line navigate to the MAMP folder (by default in your C Drive).
  4. Go to the folder called htdocs.
  5. Create a directory (folder) inside htdocs called MC_DewDropz.
  6. Make a file within MC_DewDropz and name it index.php.
  7. Open index.php in the text editor of your choosing and write: <h1>I'm writing PHP!</h1>
  8. Open up your web browser and put in the url localhost/MC_DewDropz.
  9. If you get this:

I’m writing PHP!

your local server is running and we’re ready to move on!

2) Make and “include” a header page

On M.C. DewDropz site, all the pages will have a similar header (a logo and a navbar). Of course, we could copy and paste the markup for the header on each page, but that would be a waste of time, so let’s make a header a page that we will include on every page.

  1. In your MC_DewDropz directory make a file and name it header.php.
  2. In the file header.php write: <p>This is a header</p>.
  3. Go to index.php and on the first line write (or copy and paste if that’s your thing):
<?php include 'header.php'; ?>

When you refresh localhost/MC_DewDropz in your browser – it should look something like this:

This is a header

I’m writing PHP!

Yay! You have included your header!

Starting tomorrow all the code and image files we use / write will be available in a Github Repository

Here’s a basic game plan as to what our next steps are

Setting Up Bootstrap & Connecting to MySQL

For the sake of saving time on the initial setup we will be using Twitter Bootstrap for some of the styling and behavior of our site. Tomorrow I will be going through setting up Bootstrap and making the header. Then I will be covering how to make, manage and connect to a MySQL database.

PHP Basics: Data Types, Variables, Conditional Statements, Loops and Functions

We’ll learn how to use all of these things to template our site to automatically generate from our MySQL database.

Logins and Web Forms

We’ll make an admin section where M.C. DewDropz can easily update the content his site by filling out forms that make changes to the MySQL database.

Peace Out!

Dew of your Youth

Follow Dew of Your Youth on Social Media!
Liked it? Take a second to support DewofyourYouth on Patreon!

3 thoughts on “Dewbious Intentionz – Part II : Getting Started With PHP”

Leave a Reply

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