Showing posts with label codeigniter. Show all posts
Showing posts with label codeigniter. Show all posts

Monday, 25 April 2016

Back log on the blog front.....

The rest of LAST week in Codeigniter
Wednesday April 20th 
I got most of the functionality working including reading to the database. We were given a check list in class and I checked my list of tasks from the sheet. The difficult part of this project is styling in CSS so I decided to leave it and catch up with my final year project. A large part of creative multimedia programming depends on bringing factors together; the layout (HTML), styles (CSS) , user functionality (JavaScript)  and server side functionality (Codeigniter and php with a connected database). I am starting to see the reason and big picture and how and why all of these factors come into play.

Using Codeigniter as a tool and a platform for a near enough real life project is helping me understand more about the user experience and how this ties in with designing and programming functionality into a project. The user has to be in mind at every step! 

This is what I have achieved in basic HTML and CSS it is responsive so far...

Image 1: Three responsive views of 'Go West' news site featuring day trips in the West of Ireland 


Thursday - Friday was spent on a different project - a different Codeigniter and creative multimedia programming exercise.  More about that later...

The weekend of April 23rd - 24th 
ALL Weekend was spent not trying to get the articles to be updated, deleted and read to the database like I wanted but spent getting everything to look nice! Most of Sunday was spent trying to get a registration form to style. This is what happened: when I fooled around in google inspect - (note I did NOT touch the CSS)...
Problem?
Fix? Copyied & pasted a 'good' login form to a dummy sheet and pasted the 'good' form data part from the messed up one (that I know is being read to the database) and smushing it together again.
Anyway it worked but instead of being overjoyed I was relieved that I don't have to ask another silly question!!!!

Image 2: Two navigation bars - Register User Page 

Image 3: Correct Navigation Bar - Register User Page 

This is making me wonder about this industry as a whole. Little regulation and weird stuff like this that can take hours to fix. Don't get me wrong, the levels of satisfaction I have felt this week are enormous but it is soul destroying when you can't execute any creative multimedia programming techniques that you want to do.

I am saying is it takes one away from other tasks and valuable creative/analytical thinking if you are going around in circles. Turns out I inserted two by accident and I can't seem (by Monday night to get rid of it!) .....

Also from image 3, the container id that styles the registration form in the above fields, in the Register User page seems to be semi-working today - another weird CSS thing, and horay another thing that is 'less mess' to fix. Below is the 'good' login page with all ids' being read into Codeigniter from linked assets CSS file. 


Image 4: Good log in form reading the CSS to be centered & behaving well 


 What I learned this week:
- That I can easily link & write views in codeigniter!
 - I am using the inspect element in Google & it is saving me so much !!! Thank you   Google! 
- I learned to (finally) tab my code correctly so that it mimics the natural form of the document how it is being read by the browser, whats more I understand why. A small step but enlightening.

Messy weekend programming issues continue....
I had a messy moment linking files and trying to implement the ‘alt’ attribute to an image in Codeigniter. I am still unclear which of the below is correct to use I am going to ask a tutor tomorrow I assume the latter, with the alt tags. Feel free to comment.... 

No alt tags:
 <?php echo "<img alt=\"Galway Lake with Mountains\" src=\"$img_base/assets/images/lake.jpg\" />"; ?>

Alt tags:
<img src="<?php echo $img_base . "/assets/images/skellig3.jpg"?>" alt="Skellig Bee Hive Hut" />

I am also getting red errors on inputs in a form and I don't know why but I have a feeling its because I don't understand enough about forms and buttons and taking in data from the user. I need to go back and learn about forms and buttons. We are designers, our job is to make a world with richer user experiences and lets face its all about the user in creative multimedia programming! 

Image 5: From Input Codeigniter and errors appearing (again!) 




Sunday, 24 April 2016

Not fluent in creative multimedia programming!!!!

It has been a crazy week trying to get creative ideas to execute in via creative multimedia programming. I am listening to rubbish house music partially to relax and partially because this week was spent in a lot of silence!  However, I will start the blog by saying HOW MUCH I have learned about codeigniter, its framework, functions and the general flow of data. My last post dealt with database structure and getting basic inputs from the view to controller to model and back to the controller to be sent lastly to the view.

Crawl before the wobbly walk….

I had to back track a little and last weekend I spent Sunday, all day Sunday doing a tutorial. I spent the day getting php errors in the browser but this exercise (creating a table of authors on the database) to render an updatable view to the browser was invaluable in showing me the creation of a variable and how to retrieve the data. At one point I was trying to pass a variable into itself without really understanding why. Then with help, ( phone a friend time) I had a chat and then knew I was trying to pass an array of data to the $variable. Wow a revelation. What has this to do with creative multimedia programming? Turns out everything – I can’t make anything that is dynamic, creative or functional for an end user without this skill set.

The idea here is to take another project designed to be responsive and bring it into Codeiginiter to have more functionality for the user.

Responsive GoWest News website: three views in various screen states. 



Monday April 18th 
Stepping up a bit I took our tutors project from class and had a few good reads of it to see how the ‘Local Notice’ project works. There is a lot going on in the project and covers all parts of the CRUD functions. I spoke to a few class mates, the previous Friday (April 15th) and ‘they’, the classmates, said it was  a synch to shoe horn this project into our News project. I was skeptical.
After getting little understanding from class on Monday and no further down the line of understanding I just started studying, again and going through the basic tutorial from Sunday, again.

Tuesday April 19th 
I was basically at this again all day. There was talk of the FYP (Curious Room) going into codeigniter and I got the energy from I don’t know where to try the news project first to see if I could get something working in codeigniter that actually pertained to course work. Enough messing about!

In the evening from about 7 onwards I started on the News Articles assignment, this assignment is part of two modules, advanced programming for the web and emerging web technologies. I could not get anything to work. Then after a few hours rest it dawned on me that my fields in the data base have to match every query in the PHP project exactly. I got out of bed and took a fresh file and started using the find and replace tool again, page by page, function by function. There were 17 I think in all.

 Lesson learned here: (since the previous Friday April 15th) I was trying to use the editor Netbeans but on a personal note brackets seems to suit me, a beginner in this creative multimedia programming gig a lot better. I got it working in under an hour and just thought it cannot be true. So I went to bed and looked at it on Wednesday.

There were still a lot of error messages and glitch things going on by my understanding of tracking them down is getting better, every day by reading the messages. What I learned from this project was where to find files from the controller and how the flow of information is passed from the view to the controller to the model and back to the controller again before being sent lastly with a response, an action to the user. 

I spent around 4 hours adding some navigation bars to three pages to my FYP and frankly by Saturday I could see that they were not useful, it was a lesson learned in the world of creative multimedia programming but a good lesson!
It has been a bit ridicilous trying to get two projects going in code igniter and not actually knowing: 

a) how to tackle errors 
b) how to write functions that do something unique to that project.
Consensus: A good week in exercises over all. 



Saturday, 16 April 2016

Curious Room Databases Part Two


Curious Room Data Base Showing Tables
Image 1: phpMyAdmin database showing tables


So to follow on with this ‘little’ database story, this doesn’t happen magically. I wish it did. In another module we are learning how to use the framework Codeigniter with php and the aforementioned use of databases and tables to allow basic functionality to get front end project (allowing user to meditated with a chosen avatar and other users with their avatars) and get it to pass data back and forth to the backend; the database. 

My goal is to complete the steps of CRUD. Create, read, update and delete So far using a database from class called users I have accomplished some basic programming steps. The first thing that had to be done was to create a database, in this case users. It is located in a folder called NoticeCI that exists in a Codeigniter folder. This is a list of the screen shots of what I have working:
/User/getUser
/User/User
Link: ‘edit update details’;  User\getUpdateDetails
/User/saveUserDetails

Image of controller User not found
Image 2: User/getUser

Image of controller User get user
 Image 3: User/User

Image of user get update details
Image 4: User/getUpdateDetails

Image 5: saveUserDetails

Saving user details on the database
Image 6: saveUserDetails in database (row one) It says hi Fina in Image 7 and FirstName is Fina above 
 The last one on the list is giving me a lot of trouble as I cannot save the new user details to the database. I was able to do so on 14th March in class but not now. My databases should refresh to show the new details but it is not. I have looked though the notes and the function in the saveUserDetails but I am missing something I have checked the links also in the first file called userHomePage which was userhomepage. I have gone back to the User\User folder to find any errors below or the subsequent pages the path of the framework leads to but I cannot find the issue. On my localhost nothing is happening. No even an error!!!


Here is some of the code used for programming the above : 

public function saveUserDetails($UserID){
//prepare an array of user info submittd via the POST

  $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"=> $UserID,

);


//call the function in the model to do the update and get back a boolean flag
//$flag hold tru/false value depending on whether the update was successful or not
$flag = $this->User_Model->updateUser($user);

//pass $flag to function to determine whether success/failure page should be displayed
if($flag){
//set user details in $data - this will be need inthe userhomepage
$data['User'] = $user;
$this->load->view("User/userHomePage",$data);
}else{

    $data['msg'] = "error on update to user details";
    $this->load->view('mgspage', $data);
}//end function
}
}
Okay so straight after this at exactly 5.17pm on 9th April it worked! I decided to write about what was happening to see if it would help with a) frustration and b) identify any new patterns for me to see and then I then I just decided to go back on the getUpdateDetails page, refresh, input new data and presto. It updated the database. Wow. It feels great but like any decent creative multimedia programmer I will just be looking now to do the delete functionality as I am a full WEEK behind in class. 

What did I do? It was a small typing error – the file was called getUpdateDetails not getupdatedetails as it should have been. Oh my. Who said camel casing for programming was good? Moving forward I think it will be all lower case when I can when I am programming because let’s face it trying to practice creative multimedia programming is hard to begin and then trying to implement creative concepts and execute them over a variety of platforms is another!!!  

I went for a coffee today to take a break from programming php and it taught me two things:
1.       My FYP is useful – taking breaks & doing nothing are good for creativity! Promoting this value is viable in demanding situations.
2.       Whilst on that coffee break an hour ago I told my friend’s boyfriend about taking a WEEK to find an error and he said, I quote:  ‘Now you are programming’. So in a day to find two errors myself is a happy feeling.
The next step will be to create and implement the VanilllaCI around my project Curious Room but I have to go back first and fix the actual look and basic functionality of my project before I attempt to change them into php pages. In truth I feel a bit lost about the next stem and don’t know how to do it – I have just spoken briefly with someone in the learning center about how it ‘happens’.  Apparently it’s as simple as saving the dot html extensions as dot phps… ? Hmm.  
To finish now this is working:

User/saveUserDetails

and now I just need to get a message to the home page to say the details have been updated……

I don't know how at this point how much I will be doing with creative multimedia programming but I will try my best! 



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(){
$this->load->view('User/UserLoginForm');
}
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
//var_dump($user);
 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>
<?php
$this->load->helper('url');
$base = base_url(). index_page();  

?>

<html>
<head></head>
<body>


<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">


</form>
</body>
</html>

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: fionakiely1@hotmail.com :)

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