Wednesday, 6 April 2016

Codeigniter and php - How does one progress in creative multimedia programming?

A large part of the creative multimedia programming experience and challenge is one whopper module - php. A large part of our second semester course work is to get really familiar and good at using a PHP framework such as Codeigniter, a framework used for building dynamic websites and providing manageable structure. The MVC framework stands for model, view, controller. The views are separated from the contoller which are separated from the model. The model part of the MVC holds the database and sensitive information regarding the users details. The users details are then hidden from just anyone on the outside so there is a layer (controller) to go through. The controller gives and takes information and passes it back and forth to the user (view).  This is an over simplified explanation. The main benefits of using the Codeiginiter framework are:

- RAD build rapid applications
- less repetition of code
- free
- lightweight and provides a lot of libraries for functionality to allow one to use code that is already there (less programming)
- Codeigniter is a well documented framework
- large community using Codeigniter
- form and data validation
- no configuration
- provides security and xss filtering.
- custom routing

The Codeigniter framework is one of many, others being: onextrapixel and kohana.

So far the small in class project seems to be a challenge and even though a small project was working 2 weeks ago it is not working now!!!The idea is split our final year project into separate areas for login and registeration and other functionality that should occur. Last week (our week off for Easter break) was spent debugging the project from class. I only go so far. Then this week I came into class and the loginUserForm file was working and now it is not! There was an issue alright with the notes from the php programming class - uppercase and lowercase objects and methods being called and this was confusing. There were also about 5 key errors in the code and this is hard as I am just a beginner programmer in the creative multimedia programming game. Prior to this my projects were built using tiny bits of code being strung together from simpler languages.

I think my main error occured two days ago have to go through all the function in the user.php page to to see that the pages name ie user.php matches what it is being called for through functions. This is a tedious task but hopefully I will start to fix on my own.

Image 1: 404 Error userLoginPage
One key issue that I am trying to address but my class seem to know little is the / hard escape character - where does it go? It depends, right? Standard answer. Covers everything. My understanding is that it should go where it need to to call up the function as the top, or MAIN controller at the top is calling the base page and functions after that being called and calling another page need the hard escape character some example code here

public function handleLogon(){
public function RegisterUser(){
//prepare an array o f User info submited via the POST
//left db right same as form
$user = array(
'UserName' => $_POST['UserName'],
'Password' => $_POST['Password'],
'FirstName' => $_POST['FirstName'],
'SurName' => $_POST['SurName'],
'Mobile' => $_POST['Mobile'],
'AddressLine1' => $_POST['AddressLine1'],
'AddressLine2' => $_POST['AddressLine2'],
'AddressLine3' => $_POST['AddressLine3'],
'Email' => $_POST['Email'],
'UserID' => $_POST['UserID'],
//shows what gets sent as an array
 So in the above the UserLoginForm does not need the / as I understand it but in other parts of the MVC it does as in this below does: 

this getuser.php page needs the hard escape  to call up the next page which is RegisterUser/

<!DOCTYPE html>
$base = base_url(). index_page();  



<form id="form1" name="form1" method="POST" action="<?php echo "$base/User/RegisterUser/"; ?>">

UserName <input type = "text" name = "UserName"><br>

Password <input type = "text" name = "Password"><br>

Firstname <input type = "text" name = "FirstName"><br>

SurName <input type = "text" name = "SurName"><br>

Mobile <input type = "text" name = "Mobile"><br> 

Address1 <input type = "text" name = "AddressLine1"><br>

Address2 <input type = "text" name = "AddressLine2"><br>

Address3 <input type = "text" name = "AddressLine3"><br>

Email <input type = "text" name = "Email"><br>

<input type = "submit" value="submit">


I am trying to debug and think like a programmer  but the creative multimedia programming part is definitely out for now until I get this basic functionality working! So to echo the sentiment in the title of my blog 'Codeigniter and php - How do progress in creative multimedia programming?' i don't know but I know I just have to go back over every main file, every function and check! If anyone reading this (in the world) wants to help me I have team viewer and a phone! My email is: :)

Image 2: Typical 'Undefined Index' error
Image 3: Undefined index for user details code

No comments:

Post a comment