Thursday, August 13, 2015

Day 19: PHP With MySQL

They say that one of the keys to success is getting a good amount of sleep each night. Sleep had always been in abundance and I took that for granted. Last night I got back home by 10:30pm and as much as I wanted to jump into bed I got a message from the classmate doing the hybrid route who needed additional help on another problem. I was in no state of mind to instruct her so I emailed her my work. It felt like cheating but I trust she'll take the time to review it and not just copy and submit the work. I figured that if I have my computer on I might as well look through my current assignment one more time to see what I did wrong. The first step of anything is always the hardest but once I take it that thing consumes me to the point of obsession. I finally got to bed by 11:30pm. I expected to wake up the next morning too dazed to even respond to the alarm clock. Much to my surprise I felt energetic and I just wanted to head over to the Dojo to resume the assignment.

The assignments combined everything we've leaned about MySQL and PHP. After two weeks of writing MySQl and PHP code it is all coming together as we use HTML, CSS, and Javascript to write the front-end page that users see; MySQL on standby to take in and push out data, and PHP to serve as the medium. I've been waiting for this moment for a long time; since the days in web programming when I was just taught the basics of front-end and everything else was left a mystery. I finished one assignment, then another one, and now I face The Wall.

The Wall's assignment was to build a basic social media site that users have to log into. Once logged in they can make posts and comment on others. It's basically a cheap version of Facebook that will instill in us the essentials of back-end programming. A month ago I would have had a panic attack but this last month and the last few assignments have prepared me. The only thing that holds me back these days is a good night sleep. Which I need since my brain is starting to slow down.

I did manage to gather enough energy to draw out a diagram for my website:


Each box represents a page. Every site begins on the index.php page where it collects the initial data from the user such as email, password, and username. Once that is collected and the user hits the submit button the information is passed onto the process.php page where it is analyzed and processed (as its name indicates) to the database, which is passed into the processor through the connection.php page. The user is then sent either back to the index page (usually when a piece of data is missing or formatted improperly) or sent to the main.php page, where the data is manifested along with other permitted data. The styles.css sheet adds CSS content to each of the display pages and script.js adds some behavior. 

Lets use Facebook for an analogy:
  1. When you type the site into the search tab it takes you to the main page (index.php)
  2. It is decorated a certain way (styles.css)
  3. You type in your username and password and the site takes it to the processor (process.php)
  4. After the processor validates your entries it calls the database (ex. MySQL) in to see if there is an existing account under your name (connection.php)
  5. If your account exists you are taken to your profile page (main.php) where you see you saved data and other data you are permitted to see like posts, pictures and comments
  6. If you inserted the wrong username and/or password the processor sends a warning back to index.php and displayed (script.js)
  7. When the time comes for you to log out you hit the log out button and it takes you to process.php which directs you back to index.php, concluding your usage
  8. There are a total of six pages involved in this interaction but the user will only see two of them, index.php and main.php, which is why styles.css is needed to make those pages pretty and presentable. 


I'm sure Facebook's setup is a little more complicated than the way I put it but the concept is still the same. Tasks are divided between a handful of pages and users only see a portion of them in action. 

I told myself to call it a night and dedicate all of tomorrow to working on The Wall but after setting up my diagram I got a surge of energy that I had to at least get the front page set up. Which led me to this: 


I'm doing something new where I include a navigation bar. I'm also having a laugh with this and make up some bizarre story about Facebook's unusual demise in 2019, which led to the rise of The Wall as the newest and hottest social networking site. 

Now I need some sleep and I'll be ready for an entire day of work in the morning. 

No comments:

Post a Comment