Showing posts with label itc280. Show all posts
Showing posts with label itc280. Show all posts
Saturday, June 9, 2012
ITC280 Update 10
What I learned in Week 10 of the ITC280 Class:
1) Here is how we create a session variable in PHP
if(!isset($_SESSION)){session_start();}
$sCustomerID = trim($row['CustomerID']); //Grab the Customer's unique ID, from a database
$_SESSION["sCustomerID"] = $sCustomerID; //Enter variable into session variable
2) We can clear a session by calling:
session_destroy();
3) To clear the data before destroying a session; insert an empty array:
$_SESSION = array();//copy empty array in case of failure!
4) We can silence notices and warnings by placing this code on our file
error_reporting(E_ERROR | E_PARSE); //only major problems
5) We can check the contents of the session and if the session is not set, we can send the user to a login page
if(!isset($_SESSION)){session_start();}
if(!isset($_SESSION['sCustomerID']))
{ //no session var
myRedirect("login.php?msg=5"); //send user back to login page, as session has timed out
}
6) To find and upload setting, view the PHP info command results and search for the string via the browser. For example;
upload_max_filesize
7) To be able to upload a file, we need to use the enctype attribute in our form.
<form action="upload_test.php" method="post" enctype="multipart/form-data">
8) We use the file attribute of the input element to allow a file upload.
Please select an image to test upload: <input type="file" name="image" />
NOTES:
Seriously, did I finished the final project? My teacher said that this assignment served as the last part of my final project. I really don't know why. I haven't made a project before, but let's face it. I should accept the fact that my teacher said I already finished my final project. As I recall, my teacher said that Assignments 8 to 12 served as part of the final project. Really? If I said yes, then it is. That means I done it. Question is, should I come to class on Monday and Wednesday? I should remember that next week is the last week of the Spring 2012 semester.
Never mind, I'll find out by myself.
That is all.
Labels:
itc280
Saturday, June 2, 2012
ITC280 Update 9
What I learned on Week 9 of the ITC280 class?
1) Here is a stub of a class:
class Car{}
2) Here is a simple Car object created from the car class:
$myCar = new Car();
echo $myCar->mph;
class Car
{
public $color = "";
public $mph = 0;
public $price = 0;
public $model = "";
}
3) We add a constructor to be able to load data into our object
$myCar = new Car("ferrari",100000,140,"red");
echo "MPH: " . $myCar->mph . "<br />";
echo $myCar->model;
echo $myCar->color;
echo $myCar->price;
class Car
{
public $color = "";
public $mph = 0;
public $price = 0;
public $model = "";
function Car($model,$price,$mph,$color)
{
$this->model = $model;
$this->price = $price;
$this->mph = $mph;
$this->color = $color;
4) We can Create accessor methods (get/set) to allow read/write access;
function getMPH()
{//will allow read access to a private property
return $this->mph;
}
NOTES:
It's almost the end of this class and I haven't decided on what will my final project be. Should I use the theme we used in class or use something different? That is a question I cannot answer but hey, how many lessons left before we do the final project? What should I do? I'm still stuck and I can't figure out what will my final project be...
Only one way to find out...soon...
1) Here is a stub of a class:
class Car{}
2) Here is a simple Car object created from the car class:
$myCar = new Car();
echo $myCar->mph;
class Car
{
public $color = "";
public $mph = 0;
public $price = 0;
public $model = "";
}
3) We add a constructor to be able to load data into our object
$myCar = new Car("ferrari",100000,140,"red");
echo "MPH: " . $myCar->mph . "<br />";
echo $myCar->model;
echo $myCar->color;
echo $myCar->price;
class Car
{
public $color = "";
public $mph = 0;
public $price = 0;
public $model = "";
function Car($model,$price,$mph,$color)
{
$this->model = $model;
$this->price = $price;
$this->mph = $mph;
$this->color = $color;
4) We can Create accessor methods (get/set) to allow read/write access;
function getMPH()
{//will allow read access to a private property
return $this->mph;
}
NOTES:
It's almost the end of this class and I haven't decided on what will my final project be. Should I use the theme we used in class or use something different? That is a question I cannot answer but hey, how many lessons left before we do the final project? What should I do? I'm still stuck and I can't figure out what will my final project be...
Only one way to find out...soon...
Labels:
itc280
Monday, May 28, 2012
ITC280 Update 8
What I learned at week 8:
1) Here is an example of a loaded query string
formhandler.php?id=5
2) Here is a loaded query string as viewed in the source of a list page:
<a href="view.php?id=5">My PHP Book</a>
3) Here is what the above would look like in our actual code of a list page:
print '<a href="view.php?id=' . row['BookID'] . '">' . row['BookTitle'] . '</a>';
Score:
Test # 6: 61/100 (61%)
NOTES:
As of now, I should be doing that Assignment about List/View Pages. Since because I don't have classes tomorrow due to the Memorial Day holiday, I have plenty of time to finish it but there is a bit of a problem. I haven't started my project yet. I can't decide what will my project will be but I suspect, my head is all about cars.
That's it! Maybe instead of the kittens or muffins, because Mr. Bill Newman had it with those, I decided to use those as that List/View assignment. There are some requirements on my assignment due this Wednesday..
1. A list/view application featuring the look and feel of your website (theme), that correctly displays at least 20 records from a database table of your creation. Each view page must have it's own image.
2. A link to your List page (with an appropriate name) in your application's navigation
3. A link to the SQL file you used to create the table and insert the data (on your construction page
I should be doing it now....
That is all
1) Here is an example of a loaded query string
formhandler.php?id=5
2) Here is a loaded query string as viewed in the source of a list page:
<a href="view.php?id=5">My PHP Book</a>
3) Here is what the above would look like in our actual code of a list page:
print '<a href="view.php?id=' . row['BookID'] . '">' . row['BookTitle'] . '</a>';
Score:
Test # 6: 61/100 (61%)
NOTES:
As of now, I should be doing that Assignment about List/View Pages. Since because I don't have classes tomorrow due to the Memorial Day holiday, I have plenty of time to finish it but there is a bit of a problem. I haven't started my project yet. I can't decide what will my project will be but I suspect, my head is all about cars.
That's it! Maybe instead of the kittens or muffins, because Mr. Bill Newman had it with those, I decided to use those as that List/View assignment. There are some requirements on my assignment due this Wednesday..
1. A list/view application featuring the look and feel of your website (theme), that correctly displays at least 20 records from a database table of your creation. Each view page must have it's own image.
2. A link to your List page (with an appropriate name) in your application's navigation
3. A link to the SQL file you used to create the table and insert the data (on your construction page
I should be doing it now....
That is all
Labels:
itc280
Saturday, May 19, 2012
ITC280 Update 7
What I learned on Week 7:
1) Keeps PHP from send the page before we are ready
ob_start();
2) Here we strip out the identity of the current page
define('THIS_PAGE',basename($_SERVER['PHP_SELF']));
3) There are 4 variations on include;
include()
include_once()
require()
require_once()
include creates an error but it’s catchable...
require will cause a page crash if not found
_once() makes sure a file is not loaded with
4) we can reference any other include files here
include 'credentials.php';
5) We can place all of our links in an assoc. array
$nav1 = array();
$nav1['index.php'] = "Home Page";
$nav1['email8.php'] = "Contact Us!";
$nav1['kittens1.php'] = "Kittens!";
$nav1['links.php'] = "Our Favorite Links!";
6. //this guarantees a unique title tag
$titleTag = THIS_PAGE;
7. Replace the title tag with our variable
<title><?=titleTag;?></title>
NOTES:
Well, luckily, there will be no test this weekend but I still can't think what will my final project will be. It's still to early to tell because we are still tackling more lessons and currently, we're in the process of Assignment 8 which is Themes/Functional Includes. We began since Wednesday but actually, this is too long to finish. Happily, there's still more to learn this Monday and the deadline for Assignment 8 will be Wednesday, May 23rd.
That is all...
1) Keeps PHP from send the page before we are ready
ob_start();
2) Here we strip out the identity of the current page
define('THIS_PAGE',basename($_SERVER['PHP_SELF']));
3) There are 4 variations on include;
include()
include_once()
require()
require_once()
include creates an error but it’s catchable...
require will cause a page crash if not found
_once() makes sure a file is not loaded with
4) we can reference any other include files here
include 'credentials.php';
5) We can place all of our links in an assoc. array
$nav1 = array();
$nav1['index.php'] = "Home Page";
$nav1['email8.php'] = "Contact Us!";
$nav1['kittens1.php'] = "Kittens!";
$nav1['links.php'] = "Our Favorite Links!";
6. //this guarantees a unique title tag
$titleTag = THIS_PAGE;
7. Replace the title tag with our variable
<title><?=titleTag;?></title>
NOTES:
Well, luckily, there will be no test this weekend but I still can't think what will my final project will be. It's still to early to tell because we are still tackling more lessons and currently, we're in the process of Assignment 8 which is Themes/Functional Includes. We began since Wednesday but actually, this is too long to finish. Happily, there's still more to learn this Monday and the deadline for Assignment 8 will be Wednesday, May 23rd.
That is all...
Labels:
itc280
Sunday, May 13, 2012
ITC280 Update 6
What I learned on Week 6 of the ITC280 class...
1) Here are the minimum credentials necessary to connect to MySQL via PHP
The MySQL Server Name
The MySQL UserName
The MySQL UserName's password
The name of the database
2) We use variables at the top of the page to load our credentials.
$myHostName = "localhost"; //use localhost for same machine, (zephir) or name given to you by hosting company
$myUserName = "horsey01"; //your MySQL (or Zephir) username
$myPassword = "xxxxxxxxx"; //your MySQL password (the one you made up!)
$myDatabase = "horsey01"; //db name, which is the same as our username on Zephir
3) We can store a variable with our SQL data. That way we can change it quickly.
$sql = "select * from test_Customers";
4) Here are the six steps to connect to a DB from the web:
Connect to MySQL, authenticate the MySQL users
Connect to the Database, verify authorization to this resource
Select data to be retrieved via SQL statement
Retrieve data set (result)
Loop through the data, and insert it into our page
Disconnect from MySQL, and release resources
5) We can use MySQL_num_rows to see if there is data
//loop through the data
if (mysql_num_rows($result) > 0)//at least one record!
{//show results
while ($row = mysql_fetch_assoc($result))
{
print "
";
print "FirstName: " . $row['FirstName'] . "
";
print "LastName: " . $row['LastName'] . "
";
print "Email: " . $row['Email'] . "
";
print "
";
}
}else{//no records
print '
}
6) We can create a custom error handler:
or die(myerror(__FILE__,__LINE__,mysql_error()));
SCORES:
*Pop Quiz #8 - 7/10 (67%)
*Test #5 - 73/100 (73%)
NOTES:
We did two assignments in one week! Assignment 6 involves more on adminer while Assignment 7 is involved more on db_test.php. We already done Assignment 6 but as for Assignment 7...
Clearly, some Blue Sky Thinking involved for me because since Wednesday, we did Assignment 7, which involves on db_test.php that has to be worked on two working sites. I have the SQL and I have one onto my Zephir but as for the alternative host...Well, I kinda need some blue sky thinking right now but I have to act fast because I have until Monday to finish Assignment 7.
That is all...
1) Here are the minimum credentials necessary to connect to MySQL via PHP
The MySQL Server Name
The MySQL UserName
The MySQL UserName's password
The name of the database
2) We use variables at the top of the page to load our credentials.
$myHostName = "localhost"; //use localhost for same machine, (zephir) or name given to you by hosting company
$myUserName = "horsey01"; //your MySQL (or Zephir) username
$myPassword = "xxxxxxxxx"; //your MySQL password (the one you made up!)
$myDatabase = "horsey01"; //db name, which is the same as our username on Zephir
3) We can store a variable with our SQL data. That way we can change it quickly.
$sql = "select * from test_Customers";
4) Here are the six steps to connect to a DB from the web:
Connect to MySQL, authenticate the MySQL users
Connect to the Database, verify authorization to this resource
Select data to be retrieved via SQL statement
Retrieve data set (result)
Loop through the data, and insert it into our page
Disconnect from MySQL, and release resources
5) We can use MySQL_num_rows to see if there is data
//loop through the data
if (mysql_num_rows($result) > 0)//at least one record!
{//show results
while ($row = mysql_fetch_assoc($result))
{
print "
";
print "FirstName: " . $row['FirstName'] . "
";
print "LastName: " . $row['LastName'] . "
";
print "Email: " . $row['Email'] . "
";
print "
";
}
}else{//no records
print '
What! No customers? There must be a mistake!!
';}
6) We can create a custom error handler:
or die(myerror(__FILE__,__LINE__,mysql_error()));
SCORES:
*Pop Quiz #8 - 7/10 (67%)
*Test #5 - 73/100 (73%)
NOTES:
We did two assignments in one week! Assignment 6 involves more on adminer while Assignment 7 is involved more on db_test.php. We already done Assignment 6 but as for Assignment 7...
Clearly, some Blue Sky Thinking involved for me because since Wednesday, we did Assignment 7, which involves on db_test.php that has to be worked on two working sites. I have the SQL and I have one onto my Zephir but as for the alternative host...Well, I kinda need some blue sky thinking right now but I have to act fast because I have until Monday to finish Assignment 7.
That is all...
Labels:
itc280
Sunday, May 6, 2012
ITC280 Update 5
Here's what I learned on Week 5:
1) Physical path to the root of my space on zephir;
/home/classes/ldelro02
2) Physical path to the root of my web space on zephir
/home/classes/ldelro02/public_html
3) Commands to get to my sandbox from the root of my space
cd public_html
cd Sandbox
4) Command to see all files and folders in the current directory
ls -l
5) Here are some rules regarding file permissions:
drwxrwxr-x 4 ldelro02 ldelro02 4096 Apr 23 17:13 redsplash
drwxrwxr-x 3 ldelro02 ldelro02 4096 Apr 16 15:38 RedTie
-rw-rw-r-- 1 ldelro02 ldelro02 88 Apr 9 17:55 template.php
-rw-rw-r-- 1 ldelro02 ldelro02 111 Apr 4 17:53 test.php
First three letters are your permissions
Second three are your group
Third three are the public
r = read = 4
w = write = 2
x = execute = 1
0= no permission
1= execute only
2= write only DANGEROUS!
3= write and execute DANGEROUS!
4= read only
5= read/execute
6= read/write DANGEROUS!
7= read/write/execute DANGEROUS!
DANGEROUS NUMBERS: 2, 3, 6, 7
w in the public area is world writable and a huge security risk
6) Command to create password file for .htaccess
/usr/bin/htpasswd -c ~/pass ldelro02
7) Finished .htaccess for 301 redirect:
#the following disallows access to our file
<Files .htaccess>
order allow,deny
deny from all
</files>
#the following redirects users to a genetic error page for old page addresses
ErrorDocument 404 /~ldelro02/error-404.php
#root of visible web space (virtual path in this case)
Redirect 301 /~ldelro02/old/index.php
http://zephir.seattlecentral.edu/~ldelro02/new/index.php
* POP QUIZ # 7: 10/10 (100%)
*TEST # 4: 68/100 (100%)
Notes:
So, barely an improvement on Week 5 but when it comes to finishing the extra credit on Assignment number 5, I'm afraid to tell you that creating an error 404 page would be extremely difficult for me...
How can I create a custom 404 error page and link to a 'non-existent' web page in my Zephir web space? Where would I put it on my Zephir? I have to find some help so I can finish my extra credit for Assignment 5 before Monday because for me, I haven't got a clue. This is very challenging...
1) Physical path to the root of my space on zephir;
/home/classes/ldelro02
2) Physical path to the root of my web space on zephir
/home/classes/ldelro02/public_html
3) Commands to get to my sandbox from the root of my space
cd public_html
cd Sandbox
4) Command to see all files and folders in the current directory
ls -l
5) Here are some rules regarding file permissions:
drwxrwxr-x 4 ldelro02 ldelro02 4096 Apr 23 17:13 redsplash
drwxrwxr-x 3 ldelro02 ldelro02 4096 Apr 16 15:38 RedTie
-rw-rw-r-- 1 ldelro02 ldelro02 88 Apr 9 17:55 template.php
-rw-rw-r-- 1 ldelro02 ldelro02 111 Apr 4 17:53 test.php
First three letters are your permissions
Second three are your group
Third three are the public
r = read = 4
w = write = 2
x = execute = 1
0= no permission
1= execute only
2= write only DANGEROUS!
3= write and execute DANGEROUS!
4= read only
5= read/execute
6= read/write DANGEROUS!
7= read/write/execute DANGEROUS!
DANGEROUS NUMBERS: 2, 3, 6, 7
w in the public area is world writable and a huge security risk
6) Command to create password file for .htaccess
/usr/bin/htpasswd -c ~/pass ldelro02
7) Finished .htaccess for 301 redirect:
#the following disallows access to our file
<Files .htaccess>
order allow,deny
deny from all
</files>
#the following redirects users to a genetic error page for old page addresses
ErrorDocument 404 /~ldelro02/error-404.php
#root of visible web space (virtual path in this case)
Redirect 301 /~ldelro02/old/index.php
http://zephir.seattlecentral.edu/~ldelro02/new/index.php
* POP QUIZ # 7: 10/10 (100%)
*TEST # 4: 68/100 (100%)
Notes:
So, barely an improvement on Week 5 but when it comes to finishing the extra credit on Assignment number 5, I'm afraid to tell you that creating an error 404 page would be extremely difficult for me...
How can I create a custom 404 error page and link to a 'non-existent' web page in my Zephir web space? Where would I put it on my Zephir? I have to find some help so I can finish my extra credit for Assignment 5 before Monday because for me, I haven't got a clue. This is very challenging...
Labels:
itc280
Sunday, April 29, 2012
ITC280 Update 4
1. We can use print_r to view the contents of an array.
$aFruit = array("bananas","apples","oranges");
print_r($aFruit);
2. We can use the HTML pre tag to view print_r() the way it was meant to be seen.
$aFruit = array("bananas","apples","oranges");
echo "<pre>";
print_r($aFruit);
echo "</pre>";
3. We should used var_dump() instead of print_r() because var_dump() works with almost everything.
var_dump($aFruit);
4. We can use var_dump() for more than one item:
$aFruit = array("bananas","apples","oranges");
$myName = "Leopaul";
echo "<pre>";
var_dump($aFruit,$myName);
echo "</pre>";
5. We can use a for loop to examine the contents of an array:
$aFruit = array("bananas","apples","oranges");
for($x=0;$x<count($aFruit);$x++)
{
echo $aFruit[$x] . "<br />";
}
6. We can add to an array by using empty []
$aCheese = array();
$aCheese[0] = "cheddar";
$aCheese[1] = "swiss";
$aCheese[2] = "limburger";
$aCheese[] = "gouda";
$aCheese[] = "feta";
for($x=0;$x<count($aCheese);$x++)
{
echo $x . ") " . $aCheese[$x] . "<br />";
}
7. We can use a foreach loop to go one direction only.
$aCheese = array();
$aCheese[0] = "cheddar";
$aCheese[1] = "swiss";
$aCheese[2] = "limburger";
$aCheese[] = "gouda";
$aCheese[] = "feta";
foreach($aCheese as $fromage)
{
echo $fromage . "<br />;
}
8. We can use an associative array to store string data as keys.
$nav1 = array();
$nav1["index.php"] = "Home Page";
$nav1["contact.php"] = "Contact Page";
$nav1["about_us.php"] = "About Us";
$nav1["links.php"] = "Links";
foreach($nav1 as $url => $text)
{
echo '<a href="' . $url . '">' . $text . '</a><br />';
}
9. Email1.php starting point for Wednesday
<?php
//email1.php
include 'header.php';
define("THIS_PAGE",basename($_SERVER['PHP_SELF']));
if(isset($_POST['FirstName']))
{//email data, then thank user!
echo $_POST['FirstName'] . "<br />";
echo '<a href="' . THIS_PAGE . '">RESET</a>';
}else{
?>
<form action="<?=THIS_PAGE?>" method="post">
First Name: <input type="text" name="FirstName" /><br />
Last Name: <input type="text" name="LastName" /><br />
<input type="submit" value="Email Us!" />
</form>
<?php
}//end of formhandler
include 'footer.php';
?>
10. PHP’s mail function
mail("ldelro02@seattlecentral.edu","My Subject!","My Text","noreply@seattlecentral.edu");
11. We can replace the strings with variables declared at the top of the page.
mail($ToEmail,$Subject,"My Text",$FromEmail);
12. Using var_dump() to view the entire POST array.
echo "<pre>";
Var_dump($_POST);
echo "</pre>";
13. Use PHP_EOL to create operating system specific carriage returns.
*SCORES
- Pop Quiz 5: 10/10 (100%)
- Pop Quiz 6: 10/10 (100%)
*NOTES
I'm very glad that Mr. Newman didn't give us test for this week but Assignment 4 seems to be a bit more difficult. Surely we did half of that in class but how can I finish the other half of Assingment 4 by any means of putting something like a checkbox, radio, or something that is more of a multiple choice?
It said that the form handler must:
1) Email you the information on the form
2) Include at least 2 radio buttons, 3 checkboxes, 2 textboxes and 1 textarea for comments
3) Protect itself from invalid data entry (hacking)
4) Require a valid email from the user and require first and last name textbox entry
...How can we finish this? Clearly we have to finish this by Monday midnight...
...that is all.
$aFruit = array("bananas","apples","oranges");
print_r($aFruit);
2. We can use the HTML pre tag to view print_r() the way it was meant to be seen.
$aFruit = array("bananas","apples","oranges");
echo "<pre>";
print_r($aFruit);
echo "</pre>";
3. We should used var_dump() instead of print_r() because var_dump() works with almost everything.
var_dump($aFruit);
4. We can use var_dump() for more than one item:
$aFruit = array("bananas","apples","oranges");
$myName = "Leopaul";
echo "<pre>";
var_dump($aFruit,$myName);
echo "</pre>";
5. We can use a for loop to examine the contents of an array:
$aFruit = array("bananas","apples","oranges");
for($x=0;$x<count($aFruit);$x++)
{
echo $aFruit[$x] . "<br />";
}
6. We can add to an array by using empty []
$aCheese = array();
$aCheese[0] = "cheddar";
$aCheese[1] = "swiss";
$aCheese[2] = "limburger";
$aCheese[] = "gouda";
$aCheese[] = "feta";
for($x=0;$x<count($aCheese);$x++)
{
echo $x . ") " . $aCheese[$x] . "<br />";
}
7. We can use a foreach loop to go one direction only.
$aCheese = array();
$aCheese[0] = "cheddar";
$aCheese[1] = "swiss";
$aCheese[2] = "limburger";
$aCheese[] = "gouda";
$aCheese[] = "feta";
foreach($aCheese as $fromage)
{
echo $fromage . "<br />;
}
8. We can use an associative array to store string data as keys.
$nav1 = array();
$nav1["index.php"] = "Home Page";
$nav1["contact.php"] = "Contact Page";
$nav1["about_us.php"] = "About Us";
$nav1["links.php"] = "Links";
foreach($nav1 as $url => $text)
{
echo '<a href="' . $url . '">' . $text . '</a><br />';
}
9. Email1.php starting point for Wednesday
<?php
//email1.php
include 'header.php';
define("THIS_PAGE",basename($_SERVER['PHP_SELF']));
if(isset($_POST['FirstName']))
{//email data, then thank user!
echo $_POST['FirstName'] . "<br />";
echo '<a href="' . THIS_PAGE . '">RESET</a>';
}else{
?>
<form action="<?=THIS_PAGE?>" method="post">
First Name: <input type="text" name="FirstName" /><br />
Last Name: <input type="text" name="LastName" /><br />
<input type="submit" value="Email Us!" />
</form>
<?php
}//end of formhandler
include 'footer.php';
?>
10. PHP’s mail function
mail("ldelro02@seattlecentral.edu","My Subject!","My Text","noreply@seattlecentral.edu");
11. We can replace the strings with variables declared at the top of the page.
mail($ToEmail,$Subject,"My Text",$FromEmail);
12. Using var_dump() to view the entire POST array.
echo "<pre>";
Var_dump($_POST);
echo "</pre>";
13. Use PHP_EOL to create operating system specific carriage returns.
*SCORES
- Pop Quiz 5: 10/10 (100%)
- Pop Quiz 6: 10/10 (100%)
*NOTES
I'm very glad that Mr. Newman didn't give us test for this week but Assignment 4 seems to be a bit more difficult. Surely we did half of that in class but how can I finish the other half of Assingment 4 by any means of putting something like a checkbox, radio, or something that is more of a multiple choice?
It said that the form handler must:
1) Email you the information on the form
2) Include at least 2 radio buttons, 3 checkboxes, 2 textboxes and 1 textarea for comments
3) Protect itself from invalid data entry (hacking)
4) Require a valid email from the user and require first and last name textbox entry
...How can we finish this? Clearly we have to finish this by Monday midnight...
...that is all.
Labels:
itc280
Saturday, April 21, 2012
ITC280 Update 3
What we learned on Week 3 of ITC280 Class...
1. We don’t need a closing php tag if there are no conflicts.
<? php
echo "does this work?";
2. A function that has data passed to it as a parameter.
$myPay = 50000;
areYouHappy(140000);
function areYouHappy($myPay)
{
if($myPay >= 110000)
{
echo "I'm Happy!";
}else{
echo "Not so Happy!";
}
}
3. We can use curly braces to identify the variable - with backslash added to escape dollar sign
echo "I'm Happy with the \${$myPay}!";
4. We can pass in a variable via the keyword global.
$myPay = 50000;
areYouHappy();
function areYouHappy()
{
global $myPay;
if($myPay >= 110000)
{
echo "I'm Happy with the \${$myPay}!";
}else{
echo "Not so Happy with the \${$myPay}!";
}
}
5. Use the keyword return to pass data out of a function.
$myPay = 50000;
echo areYouHappy();
function areYouHappy()
{
global $myPay;
if($myPay >= 110000)
{
return "I'm Happy with the \${$myPay}!";
}else{
return "Not so Happy with the \${$myPay}!";
}
}
6. We can pass the data in as a parameter, and add br tags for readability.
$myPay = 50000;
echo areYouHappy($myPay);
echo areYouHappy(5);
echo areYouHappy(140000);
echo areYouHappy(30);
function areYouHappy($myPay)
{
if($myPay >= 110000)
{
return "I'm Happy with the \${$myPay}!<br />";
}else{
return "Not so Happy with the \${$myPay}!<br />";
}
}
7. Text is the default type attribute for the input element.
First Name: <input name="FirstName" />
8. An example of data in a querystring
forms1.php?FirstName=Leopaul
9. If we have more than one piece of data, it is separated by ampersand.
forms1.php?FirstName=Leopaul&LastName=DelRosario
10. If a value has a space, it is replaced with a plus sign.
FirstName=Leo+Paul&LastName=Del+Rosario
11. Our first web application.
if(isset($_POST['FirstName']))
{
echo $_POST['FirstName'];
}
12. Our first REAL web application.
<html>
<body>
<?php
if(isset($_POST['FirstName']))
{
echo $_POST['FirstName'];
echo '<br /><a href="forms2.php">RESET</a>';
}else{
?>
<form action="forms2.php" method="post">
First Name: <input type="text" name="FirstName" /><br />
Last Name: <input type="text" name="LastName" /><br />
<input type="submit" />
</form>
<?php
}
?>
</body>
</html>
13. Example of a superglobal. It gives us the current file name.
$_SERVER['PHP_SELF']
14. Force cast data to an integer
$myTires = (int)$_POST['Tires'];//forced cast to int
NOTES:
Sadly, my scores at Pop Quiz # 4 and Test # 3 are badly. For Pop Quiz # 4, I got 67% then on Test # 3, it's a 50%. Can't believe that most of the questions here are extremely difficult. I tried looking back at past lessons but the questions are too complicated to answer. Next time, I should remain focused on my class in order to get a better grade.
Speaking of which, I am currently working on Assignment # 3, which is the Troubleshooting Exercise. Due Monday, Apr. 23rd. In class, we only finished 5 out of 10 errors to find on this assignment. The trouble is, how can I find the remaining five errors?
Anyway, Mr. Newman set up the fixed version but the link is broken. I e-mailed him to get this link to the fixed "adder.php" page fixed so I can get the five remaining errors found. God, help us...
SCORES:
Pop Quiz # 4 - 7/10 (67%)
Test # 3 - 9/18 (50%)
1. We don’t need a closing php tag if there are no conflicts.
<? php
echo "does this work?";
2. A function that has data passed to it as a parameter.
$myPay = 50000;
areYouHappy(140000);
function areYouHappy($myPay)
{
if($myPay >= 110000)
{
echo "I'm Happy!";
}else{
echo "Not so Happy!";
}
}
3. We can use curly braces to identify the variable - with backslash added to escape dollar sign
echo "I'm Happy with the \${$myPay}!";
4. We can pass in a variable via the keyword global.
$myPay = 50000;
areYouHappy();
function areYouHappy()
{
global $myPay;
if($myPay >= 110000)
{
echo "I'm Happy with the \${$myPay}!";
}else{
echo "Not so Happy with the \${$myPay}!";
}
}
5. Use the keyword return to pass data out of a function.
$myPay = 50000;
echo areYouHappy();
function areYouHappy()
{
global $myPay;
if($myPay >= 110000)
{
return "I'm Happy with the \${$myPay}!";
}else{
return "Not so Happy with the \${$myPay}!";
}
}
6. We can pass the data in as a parameter, and add br tags for readability.
$myPay = 50000;
echo areYouHappy($myPay);
echo areYouHappy(5);
echo areYouHappy(140000);
echo areYouHappy(30);
function areYouHappy($myPay)
{
if($myPay >= 110000)
{
return "I'm Happy with the \${$myPay}!<br />";
}else{
return "Not so Happy with the \${$myPay}!<br />";
}
}
7. Text is the default type attribute for the input element.
First Name: <input name="FirstName" />
8. An example of data in a querystring
forms1.php?FirstName=Leopaul
9. If we have more than one piece of data, it is separated by ampersand.
forms1.php?FirstName=Leopaul&LastName=DelRosario
10. If a value has a space, it is replaced with a plus sign.
FirstName=Leo+Paul&LastName=Del+Rosario
11. Our first web application.
if(isset($_POST['FirstName']))
{
echo $_POST['FirstName'];
}
12. Our first REAL web application.
<html>
<body>
<?php
if(isset($_POST['FirstName']))
{
echo $_POST['FirstName'];
echo '<br /><a href="forms2.php">RESET</a>';
}else{
?>
<form action="forms2.php" method="post">
First Name: <input type="text" name="FirstName" /><br />
Last Name: <input type="text" name="LastName" /><br />
<input type="submit" />
</form>
<?php
}
?>
</body>
</html>
13. Example of a superglobal. It gives us the current file name.
$_SERVER['PHP_SELF']
14. Force cast data to an integer
$myTires = (int)$_POST['Tires'];//forced cast to int
NOTES:
Sadly, my scores at Pop Quiz # 4 and Test # 3 are badly. For Pop Quiz # 4, I got 67% then on Test # 3, it's a 50%. Can't believe that most of the questions here are extremely difficult. I tried looking back at past lessons but the questions are too complicated to answer. Next time, I should remain focused on my class in order to get a better grade.
Speaking of which, I am currently working on Assignment # 3, which is the Troubleshooting Exercise. Due Monday, Apr. 23rd. In class, we only finished 5 out of 10 errors to find on this assignment. The trouble is, how can I find the remaining five errors?
Anyway, Mr. Newman set up the fixed version but the link is broken. I e-mailed him to get this link to the fixed "adder.php" page fixed so I can get the five remaining errors found. God, help us...
SCORES:
Pop Quiz # 4 - 7/10 (67%)
Test # 3 - 9/18 (50%)
Labels:
itc280
Sunday, April 15, 2012
ITC280 Update 2
My progress at Week 2 of ITC280;
1. We can use the phpinfo() function to see what settings our clients have on their host server phpinfo();
2. We can use a variable and concatenate it with a string.
$myName = "Leopaul";
echo "My Name is " . $myName;
3. We can use variables replacement as long as we use double quotes.
$myName = "Leopaul";
echo "My Name is $myName";
4. Variable replacement using numbers
$myNum = 4;
$myOtherNum = 1;
$myTotal = $myNum + $myOtherNum;
echo "I added $myNum and $myOtherNum and the total is $myTotal";
5. Using gettype()
$myNum = 4;
echo "<br />myNum is " . gettype($myNum)." type";
6. Showing the limits of the double numeric type
$myNum = 2;
$myOtherNum = 3;
$myTotal = $myNum / $myOtherNum;
echo "I divided $myNum by $myOtherNum and the total is $myTotal";
echo "<br />myTotal is " . gettype($myTotal)." type";
7. The equals sign is the assignment operator
$myNum = 2;
$myNum = $myNum + 1;
echo "myNum is $myNum";
8. += is a compound operator that appends additional data.
$myNum = 2;
$myNum = $myNum + 1;
echo "myNum is $myNum";
9. We can increment with ++ and decrement with -
$myNum = 2;
$myNum++;
echo "myNum is $myNum";
10. How to create a dynamic copyright.
<em>© 2002-<?php echo date('Y'); ?></em>
11. Short tags are bad and I will never use them but if I do...
<em>© 2002-<?=date('Y')?></em>
12. Example of an if statement.
$myNum = 1;
$myOtherNum = 1;
if($myNum == $myOtherNum)
{
echo "They are equal!";
}
13. Example of an if else statement
$myNum = 2;
$myOtherNum = 1;
if($myNum == $myOtherNum)
{
echo "They are equal!";
}else{
echo "They are NOT equal!";
}
14. Constants once filled cannot be changed and are constantly available.
define("MY_PAY" ,35000);
if($myPay >= 110000)
{
echo "I'm happy!";
}else if(MY_PAY >= 85000){
echo "I'm marginally happy!";
}else{
echo "Not so happy!";
}
15. We can create a function to store code we want to reuse.
function areYouHappy()
{
if(MY_PAY >= 110000)
{
echo "I'm happy!";
}else if(MY_PAY >= 85000){
echo "I'm marginally happy!";
}else{
echo "Not so happy!";
}
}//end areYouHAppy()
* Pop Quiz # 2 score; 7/10 (67%)
* Test # 2 score: 72/100 (72%)
* Time spent total: 5 hours 11 minutes
NOTES: Back in Wednesday, at the near end of the ITC280 class, we did the Assignment # 2, which involves on cutting up two existing third party HTML designs into include files to create two different usuable and professional looking PHP templates. On class, we did just one out of two, but it's a bit more complicating. Happily, however, Mr. Bill Newman, our teacher, will help us do another one on Monday.
That is all... Thank You...
1. We can use the phpinfo() function to see what settings our clients have on their host server phpinfo();
2. We can use a variable and concatenate it with a string.
$myName = "Leopaul";
echo "My Name is " . $myName;
3. We can use variables replacement as long as we use double quotes.
$myName = "Leopaul";
echo "My Name is $myName";
4. Variable replacement using numbers
$myNum = 4;
$myOtherNum = 1;
$myTotal = $myNum + $myOtherNum;
echo "I added $myNum and $myOtherNum and the total is $myTotal";
5. Using gettype()
$myNum = 4;
echo "<br />myNum is " . gettype($myNum)." type";
6. Showing the limits of the double numeric type
$myNum = 2;
$myOtherNum = 3;
$myTotal = $myNum / $myOtherNum;
echo "I divided $myNum by $myOtherNum and the total is $myTotal";
echo "<br />myTotal is " . gettype($myTotal)." type";
7. The equals sign is the assignment operator
$myNum = 2;
$myNum = $myNum + 1;
echo "myNum is $myNum";
8. += is a compound operator that appends additional data.
$myNum = 2;
$myNum = $myNum + 1;
echo "myNum is $myNum";
9. We can increment with ++ and decrement with -
$myNum = 2;
$myNum++;
echo "myNum is $myNum";
10. How to create a dynamic copyright.
<em>© 2002-<?php echo date('Y'); ?></em>
11. Short tags are bad and I will never use them but if I do...
<em>© 2002-<?=date('Y')?></em>
12. Example of an if statement.
$myNum = 1;
$myOtherNum = 1;
if($myNum == $myOtherNum)
{
echo "They are equal!";
}
13. Example of an if else statement
$myNum = 2;
$myOtherNum = 1;
if($myNum == $myOtherNum)
{
echo "They are equal!";
}else{
echo "They are NOT equal!";
}
14. Constants once filled cannot be changed and are constantly available.
define("MY_PAY" ,35000);
if($myPay >= 110000)
{
echo "I'm happy!";
}else if(MY_PAY >= 85000){
echo "I'm marginally happy!";
}else{
echo "Not so happy!";
}
15. We can create a function to store code we want to reuse.
function areYouHappy()
{
if(MY_PAY >= 110000)
{
echo "I'm happy!";
}else if(MY_PAY >= 85000){
echo "I'm marginally happy!";
}else{
echo "Not so happy!";
}
}//end areYouHAppy()
* Pop Quiz # 2 score; 7/10 (67%)
* Test # 2 score: 72/100 (72%)
* Time spent total: 5 hours 11 minutes
NOTES: Back in Wednesday, at the near end of the ITC280 class, we did the Assignment # 2, which involves on cutting up two existing third party HTML designs into include files to create two different usuable and professional looking PHP templates. On class, we did just one out of two, but it's a bit more complicating. Happily, however, Mr. Bill Newman, our teacher, will help us do another one on Monday.
That is all... Thank You...
Labels:
itc280
Thursday, April 5, 2012
ITC280 Update 1
As some you know, I am currently taking ITC280 at the Seattle Central Community College. I'll be using this blog to save my progress during class. This will help my teacher, Mr. Bill Newman, keep tabs in my progress. All comments and suggestions are highly appreciated.
My current progress as follows:
- As of now, I made a blog post, which is part of ITC280's Assignment One and I did now.
- Yesterday, during class, I already made the ITC280 Staging Page, which you can see one at https://docs.google.com/document/d/1Zm_vU1CqCzqijl-H1Ip3NtyhI1w35GimO5H_DZeY5ro/edit
- Worked on the Time Tracker Spreadsheet
- I am still waiting for my ordered book, titled PHP for the Web: Visual QuickStart Guide (4th Edition)
by Larry Ullman, to arrive in my home
- Working on the Week 1 Class Exercises
...That is all.
My current progress as follows:
- As of now, I made a blog post, which is part of ITC280's Assignment One and I did now.
- Yesterday, during class, I already made the ITC280 Staging Page, which you can see one at https://docs.google.com/document/d/1Zm_vU1CqCzqijl-H1Ip3NtyhI1w35GimO5H_DZeY5ro/edit
- Worked on the Time Tracker Spreadsheet
- I am still waiting for my ordered book, titled PHP for the Web: Visual QuickStart Guide (4th Edition)
by Larry Ullman, to arrive in my home
- Working on the Week 1 Class Exercises
...That is all.
Labels:
itc280
Subscribe to:
Posts (Atom)