A potpourri of Web Developmemt, Linux, and Windows tidbits and observations

Ubuntu – The Terminal Window

Posted by dale | Linux,Ubuntu | Sunday 31 January 2010 12:04 pm

One of the things that separates Windows from Linux or Ubuntu, a Linux distribution, is the way the operating system handles the graphical user interface. Microsoft Windows is an integral part of the operating system. It is integrated with the operating system and at this point, Windows 7, you can’t operate the computer with out the Window’s graphical interface. To be fair, you can still get to the old DOS command line by typing cmd in the run window, but it’s more there for a link to nostalgia, than it is to do day to day operations. In a lot of ways, I miss the DOS command line, I was good at it. Alas, even some of the old DOS commands are missing, like fdisk, for example. That’s all done through the windowing system, now.

In contrast, Linux has two windowing systems, KDE, and the one used in Ubuntu, Gnome. These two windowing systems are independent applications, and more important, they run as applications, just like OpenOffice or a game would run.

Linux consists of a kernal, and another layer that runs user applications, and never the twain shall meet. The kernal uses its own memory space, and each application runs in its own memory segment. If an application needs to access a disk drive, it calls the kernal, the kernal accesses the drive, and passes the information over to the calling applications memory space. Because of this the desktop can crash, say from a video game that has a bug, and it will not bring the computer down. It will just shut down that application, which you can restart from the Linux command line.

In contrast, Microsoft integrates windows with the operating system. So if you have a problem with your video driver, the entire system crashes, and you have to reboot the computer. This is one of the reasons Linux is more secure than Windows.

I mentioned you can restart an application from the command line in Ubuntu. How do we get there?  In Windows, you type cmd in the run window, and you get a black window with the command prompt.  Ubuntu is pretty much the same.  From the Gnome desktop, in the upper left corner, go to Applications->Accessories->Terminal. You’ll find a nice black window pop up with a $ prompt. Welcome to the Ubuntu Linux distribution command line.

Bringing Up the Ubuntu Terminal Window

Putting an Icon on Your Desktop

As a digression, I am at the command prompt much more often than in Windows, so I put an icon on my desktop to bring it up quickly.  To put an icon on your desktop, go back to Applications->Accessories->Terminal, but instead of left clicking to bring up the window, right click, and your given a couple of choices. You can add an icon to the laucher panel, this is a tiny icon that appears on the top bar of your screen, like the current Firefox icon, or you can add the icon to your desktop.

There is another choice, of putting it in the menu, as a drawer, the equivalent of a folder in Windows, or a an actual menu item.  Since we’re making an icon for the desktop, we don’t need to put it in the menu, since it’s already there.  By the way,  if you would like to rearrange your menus, change the drawers, or remove some menu items, the menus are completely configurable.  Go to the Applications choice on the top menu bar, for example, right click and select “Edit Menus.”

Back to the terminal window, the terminal window gives you complete access to the Ubuntu distro,  i.e. the Linux operating system command line, and its plentiful commands, but that is the subject of another post.  As a teaser, I’ll give you a couple of commands to get you started.    Everything is in lower case, type “pwd” for print working directory.   It tells you where you are.  Type, “ls” to list the files in that directory, or better “ls -al” to get a long alphabetical listing.  Some things come from DOS.  Type “cd ..” for change directory  to move up one level in the directory structure, and or to go down, type the name of the directory , for example,  “cd home”  goes down to the home directory, that should keep you busy for awhile.  Have fun and enjoy Ubuntu.

And finally, less we get carried away, you can still explore your file system through the GNOME graphical user interface, like Windows Explorer, without using the terminal window or the command line, by going to the “Places” menu in the upper tool bar.

Passing Variables – PHP Post – Fun with Forms

Posted by dale | PHP,XHTML | Saturday 30 January 2010 12:21 am

In my last post, we covered the GET method, get is one of two methods used to get information from the client’s browser to the server, the other method being “POST.” You’ll find that “post,” by a wide margin, is the method used by developers, over the less secure, “get.”

The post method is used when you have a large amount of data in your form, and when you want to be more secure with the data, and not have it so visible, as with the “get” method.

Let’s have a little fun and review forms a bit, we’ll start with a form the developer might put on a page for the user to fill out in his browser window. Here’s the body of the html with the form.

Tell Us about Yourself

My favorite ice cream flavors are (pick all that you like): French Vanilla Chocolate Black Rasberry Vanilla Fudge Strawberry Cookie Dough Coffee What is your favorite pet? Dogs Cats Horses Parrots Snakes I don't like pets What is the make of the current car you drive: Tell us about your favoite hobby and why you like it:

And here is what the form will look like in the browser. I’ve filled in some example data in the form in the browser window for us to use in the next file. In this case the form action will send the form information to “formctrl.php” which we’ll will use to echo out the data.

Here is the php code, minus the php tags, we’ll use to retrieve the data in the “formctrl.php” file, and then, in this case, echo out the data to the screen. Notice that the syntax to retrieve the data is the same as we used for “get,” except we substitute the word, “post,” instead. The data variable in the post portion comes from the “name” tag in the form for each input method.

In the case of asking for ice cream flavors, we selected more than one choice, so we created an array by putting an [] after the name in he checkbox, called, “checkit[]” To retrieve the data from the array, we initialized an array variable in the next file, “$checked,” and then use a foreach loop, and go through the array one choice at a time to retrieve the choices.

$fname   = $_POST['fname'];                  // First Name
$lname   = $_POST['lname'];                  // Last Name
$checked = array();
$checked  = $_POST['checkit'];              // Ice Flavors
$radsel   = $_POST['radioselect'];           // Favorite Pet
$dropcar   = $_POST['dropdowncar'];      // Car
$note   = $_POST['notes'];                    // Comments

echo "And now let's check the data from the form.";
echo "";
echo "";
echo "Hello, Mr. ". $lname . ",";
echo "";
echo "Or can we call you, ". $fname ."," ;
echo "";
echo "What are some of your favorite ice cream flavors?";
echo ""; 

foreach ($checked as $ic ){
   echo "I like ". $ic ."";
   }

echo "";
echo "And what is your favorite kind of pet? ". $radsel .".";
echo "";
echo "";
echo "Thanks ". $fname.",";
echo "";
echo "Can you give me a ride?  ";
echo "What kind of car do you drive?";
echo "";
echo "Yes, a ".$dropcar .".";
echo "";
echo "Any thing more you'd like to say?: " . $note  ;
echo "";
echo "OK, What ever you say, Let's go! ";

And here is what the output of the above file will look like in the browser window.

I think from the above example you can see why “post” is the most popular method used with forms, the user’s data remains hidden until you specifically get the data in the next file.

We’ve covered passing the user’s information from his browser to a file on the server. We’ll next move on to keeping information about an individual user separate from another user, and retrieving it later.

Oracle acquires Sun

Posted by dale | Companies,MySQL | Thursday 28 January 2010 1:58 pm

Wow, this is big. It is no secret that Sun has fallen on some tough times lately. Sun had a total revenue of $11.45 billion last year down from $13.88 billion the year before. In contrast, Oracle’s last year revenues were $23.23 Billion. The combined revenues of both companies should approach $35 billion. Microsoft currently checks in at $56.3 billion. We’re looking at the heavy weights going at it. With Microsoft on the decline, Google at $23.65 billion on the rise, and now Oracle stepping up into the fray, this may become a very interesting war. Oracle acquired Sun for a mere $7.4 billion, a steal.

Oracle’s revenue comes from it’s pervasive Oracle database. Depending on how you look at it revenue, or installs. Oracle is in the top 2 with Microsoft and IBM’s DB2 a close third. Let’s not forget, MySql is the most popular Open Source, i.e free, database in the world. What is surprising is when you look at installs and the number of developers developing with a database, MySql comes in a close 3rd to Oracle and Microsoft, with DB2 fourth, and MySql shows the greatest growth rate of all database development.

Oracle’s acquisition of the MySql product may be a problem for the Open Source community. Sun owned MySQL, which now belongs to Oracle. If you remember, Oracle purchased PeopleSoft in Dec. 2004 for $10.3 billion. In Oct, 2005 they acquired Innobase which is an integral part of MySql for transaction processing and foreign keys. What will Oracle do with MySql has caused a huge concern with the Open Source Community, so much so, that their already has been several forks of MySql, Drizzle, and MariaDB, just in case Oracle starts charging for MySql. For now, Oracle pledges to leave MySql independent, but this is to be expected in the initial stages of an acquisition, things usually change in six months or so.

My thought is they will continue to support an Open Source MySql and build on top of MySql additional tools, extensions, and integrations with other Oracle products with, of course, a clear upgrade path to Oracle’s flagship products for which the enterprise users will pay dearly.

And the same for OpenOffice.org, a legitimate contender, now, of Microsoft Office. Oracle has never had an Office Suite and has wanted one. Oracle is built with Java, as is OpenOffice.org. Again, tools, extensions, and integrations with Oracle products seems like a nice way to get users to start paying for more and more functionality from a previously non-existent Oracle Office Products.

Oracle keeping the Open Source products they have acquired free, and enhancing them, at first, to gain market share seems like good business sense, but as these applications gain more and more market share, I believe Oracle will take a page from Microsoft’s play book, and start charging for their enhancements to the products. What this means for Open Source, is a freezing of the Open Source components to a minimal feature level, and if you want more, pay for it.

I have great faith in Open Source software, the forking of MySql is evidence that independent Open Source Developers will continue to create other applications with the missing functionality, that Oracle will ask customers to purchase. As MySql has emerged as the premier Open Source database, so other products can, and will, emerge to take its place, if Oracle begins to get as “bean counterish” as Microsoft is currently, with it prideful boasting about “Microsoft Genuine Advantage,” and its publicly crowing about the number of companies they have sued, look for any closing down, of previously Open Source Oracle products to be a catalyst to breed a new generation of improved Open Source products.

Passing Variables – PHP Get – Get it!

Posted by dale | PHP,XHTML | Wednesday 27 January 2010 1:46 am

Last post we talked about how we normally get data into a system with a form. The user enters his information into the form and clicks the submit button. The browser then sends the data to the server.

Back at the server, php sets aside some memory, the server stores the information in that memory location, and calls the next page. That page is what the developer specified in the form command.

Here’s the form again:

In this case, the action parameter tells the server what file to go to next, controller.php.

The more interesting questions are how the browser passes the information to the server, and how the controller.php file gets that information out of memory. Those questions are answered by the method parameter in the form tag, in this case, GET. Get is one of the two methods you can use to get data from the browser to your program file.

The GET method tells the browser to package the site and form data as part of the URL sent to the server calling the next page. For example, if we go to the W3C site at http://www.w3.org/ , and in the Google search box on the right side type, “CSS,” click the magnifying glass, and look at the URL at the top of the page.

You’ll see: “http://www.google.com/search?q=site:w3.org&q=css&search-submit=” The browser packaged the site “w3.org”, the variable data, “css,” and the variable, “search,” into the URL after the “?”

Now, to get this information into the controller.php file with use the php $_GET method.

And here’s how you get the data into the controller.php file:

$searchinfo = $_GET['searchit'];

Notice how the name parameter of the input tag, searchit, is the name of the variable we use to GET the information back out of memory.

if we echo the variable we just created, $searchinfo ,

echo "The search word is: ". $searchinfo;

The answer we get is:

The search word is: css

We’ve passed the data from the form input page to the controller.php page.

Now some thoughts. The best place to use get is with queries, as shown above, not when your passing sensitive information, like your social security number. Why? For obvious reasons, all your information is in the URL for anybody to see. GET is not secure, but for a search box, it’s fast and easy.

Another thing, the URL has a maximum size. Surprising it is mostly set by the browser you use, Internet Explorer is 2048 characters, Firefox is 65,536, Safari is 80,000 and Opera in 190,000. Nothing to really worry about, but its best to keep the “Get” method to short queries back to the server. Get gets a bad rap for messing up the URL line, and putting the data out there for everyone to see. It’s not used that much, except for search queries, mostly form data is posted, which we’ll talk about next.

Passing Variables – HTML Forms – Creating Data with Forms

Posted by dale | PHP,XHTML | Friday 22 January 2010 11:12 pm

We can’t pass data to another page until we have some data.  The way we  input data in web pages is with forms.  Forms are created with html, more easily created with html then styled in CSS, but that’s another article.

Forms are created with the <form> tag, and of course, the form ends with a </form> tag.  Form is a block element.  Any submitting elements between these two tags are processed as being part of the form.

Let’s create a form with some input elements as an example of proper html syntax:




Pencil: Notebook: Textbook: Pack:
Cauleflour Brussel Sprouts Black Beans

The above code yields a form that looks like the image below in your browser (click to enlarge image).

You fill in the form on the web page, click the, “Click me when the form is filled out!” button, and the data you entered into the form is sent to the file “../controllers/example_controller.php” which you specified in the action parameter in the opening form tag.

Some notes on the form itself, I included a hidden field not displayed in your browser window.  Now don’t get excited about secret codes, or something evil you could pass in to the site, because this is not secure.  All you have to do is View->PageSource in your browser, and you can see the “hidden field” value. It is not used a lot because of this, but it can be used if you want to pass some data to another page when the form is submitted that would not be normally obvious to a user.

You’ll notice that each type of input has a “name” tag. The “name” tag is important, it’s how you identify the the data that is coming to the next page.  For example, the name of the first input box is “firstname,” when I get to the next page, I’m going to ask for “firsname” when I want the contents of that input, Which brings us to the topic at hand, passing data to another page.

We can pass form data to the, “../controllers/example_controller.php” file in one of two ways either “Get,” or “Post.”  The method we use to send the data is a parameter in the initial form tag, like so, method = “post,” or method=”get”  We’ll cover this in our next article.  For now, in our initial web page we have collected the data, when the user clicks on the submit button, we pass the data to another page or file.  And we’ll talk about what the receiver file has to do to catch the data in our next article.

Next Page »