Quantcast

How Do You Design Your Myspace Profile

(1 votes, average: 3 out of 5)
Loading ... Loading ...

If you're new here, you may want to subscribe to my RSS feed. So that you can read the latest updates about Web2.0 tools, Making Money Online, Tips in SEO, Ajax and many more. Thanks for visiting ProgramimiCOM!

Ok, so you’ve created a Myspace page from the Myspace login page and now you have the task of designing your Myspace layout to best express yourself, your personality, your business or your band. How do you do this? How can you create a cool Myspace layout that will attract thousands of users? Adding interesting colors, graphics, fonts, videos and photos is one way to go about it. When you create a Myspace layout that rivals the best Myspace pages out there, you will soon see that your number of friends can quickly jump into the thousands, creating a network of over ten million people.

That’s a lot of eyes! The more people you get to view and add to your friends, the larger your network of contacts becomes. Using an easy-to-use Myspace layout is the way to create a more interesting Myspace page. When you visit your friend’s pages, which pages are the most interesting and hold your attention? Do some research and search around Myspace to find out what kind of Myspace layouts and Myspace backgrounds attract you the most. Copy the style of these Myspace pages and make your Myspace page the hottest Myspace layout in town!

It’s no secret that Myspace music is a key element to your cool Myspace page. Finding music on Myspace is no problem, search around on band pages to hear some new music and find a song that you want to include on your profile page. This song will automatically start (unless you edit the Myspace code) and your users will have a soundtrack to your page while they view it! Your musical selection will give your viewers an idea of your sense of style and personality.

Whether you prefer hip-hop, rap. Rock and roll, country western, Christian religious, heavy metal, R&B, easy listening, jazz, emo, alternative or hard core punk rock, you will find a song that suits your mood on Myspace music. Once you find the song you want to add, simply add the Myspace music code into your profile and you ‘ll have your users jamming along with you. Change it three times a day, if you like! The limit is really only your imagination when you are creating your Myspace layout.

Yesterday, you wanted a cute Myspace layout, but today, you’re feeling a little more like finding a free hot Myspace layout to suit your mood. Did your boyfriend break up with you and now you are feeling a little less like glittery, pink stars and a little more like black and red skulls and crossbones? No problem. You can update your Myspace layout any time. Find some Myspace graphics or Myspace icons for your Myspace layout and add a little fun to your profile page with moving animations. You can even change the Myspace cursor from the regular cursor to an animated turquoise glitter guitar if you want to! Everybody who is anybody wants to have a pimped out Myspace layout and you can have it, too. It’s easy to update your profile page layout with user-friendly Myspace generators such as the ones found at getonmyspace.com.

By:

Whether you prefer hip-hop, rap. Rock and roll, country western, Christian religious, heavy metal, R&B, easy listening, jazz, emo, alternative or hard core punk rock, you will find a song that suits your mood on Myspace music. Once you find the song you want to add, simply add the Myspace music code into your profile and you ‘ll have your users jamming along with you. Change it three times a day, if you like! The limit is really only your imagination when you are creating your Myspace layout.

Yesterday, you wanted a cute Myspace layout, but today, you’re feeling a little more like finding a free hot Myspace layout to suit your mood. Did your boyfriend break up with you and now you are feeling a little less like glittery, pink stars and a little more like black and red skulls and crossbones? No problem. You can update your Myspace layout any time. Find some Myspace graphics or Myspace icons for your Myspace layout and add a little fun to your profile page with moving animations. You can even change the Myspace cursor from the regular cursor to an animated turquoise glitter guitar if you want to! Everybody who is anybody wants to have a pimped out Myspace layout and you can have it, too. It’s easy to update your profile page layout with user-friendly Myspace generators such as the ones found at getonmyspace.com. Including the new Harry Potter Comments to elebrate the release of the new movie by sending your friends a great Harry Potter Comment using those free Harry Potter Myspace comment codes.

By: broniac

Member Managment System Using PHP, AJAX - Part 3

(No Ratings Yet)
Loading ... Loading ...

In parts one and two of this tutorial we covered the user side of things, now we have to handle our administration area. This is going to be pretty simple, but the cool thing is that it will integrate totally with all our existing code.

In order to protect the PM page from guests, we set our MIN_AUTH_LEVEL constant to 1, so all we need to do in order to only let administrators in is to make that value 2. Sweet.

All the admin panel will do is let you edit users data (not password, you sneaky little. . .) and gives a simple splash page with some basic stats.

File: admin.php

 

<?php
session_start();
//Only administrators can get in here
define(‘MIN_AUTH_LEVEL’, ‘2′);
include(‘./config.php’);
//Only one option, eh.
$menubar = ‘<table><tr><td><a href=”?do=users”>Manage Users</a></td></tr></table>’;
$footer = “<p><a href=’”. SITE_URL .“‘>Home</a> - <a href=’”. SITE_URL .“login.php?do=logout’>Logout</a></p>”;
if($_GET[‘do’] == )
{
//Basic information, pretty much useless in our case, but may not be for others
$title = ‘Admin Home’;
$con = “<h2>Admin Home</h2>
Quick Stats:
<ul>
<li>Members: “
. count_tbl(‘users’) .“</li>
<li>PM’s: “
. count_tbl(‘messages’) .“</li>
</ul>”
;
}

The above is just setting the auth level, than doing our simple, and rather pointless, splash page. Next up is the cool part, the user editing. No, there’s no reloading the page, you just click save or delete and it’s done, all with some pretty effects. We’re going to use our get_all_users() function to return a neat array of every user, then all we do is foreach() through each one.

File: admin.php (continued)

 

else if($_GET[‘do’] == ‘users’)
{
//Get an array of every user we have
$users = list_all_users();
$title = “Manage Users”;
$con = “<h2>Manage Users</h2>
<p>Click the save icon to update the user’s details, and the x to delete the user (not undoable!)</p>
<form>
<table border=’1′>
<tr><th>Username</th><th>Name</th><th>E-Mail</th><th>Auth Level</th><th>Options</th></tr>”
;
//A mess of code, I know. It lists the details for every user, except password, and assigns each TD a unique ID so that the JS can get the value when saving. The icons let you save your work or delete the user.
foreach($users as $v)
{
$con .= “<tr id=’user_{$v[’id’]}’><td><input type=’text’ id=’username_{$v[’id’]}’ value=’{$v[’username’]}’ /></td><td><input type=’text’ id=’name_{$v[’id’]}’ value=’{$v[’name’]}’ /></td><td><input type=’text’ id=’email_{$v[’id’]}’ value=’{$v[’email’]}’ /></td><td><input type=’text’ id=’auth_{$v[’id’]}’ value=’{$v[’admin’]}’ /></td><td align=’center’><a href=’#’ onclick=\”edit_user(’{$v[’id’]}’);\”><img src=’./images/save.png’ alt=’save’ style=’border:none;’ /></a> - <a href=’#’ onclick=\”delete_user(’{$v[’id’]}’, ‘{$v[’username’]}’);\”><img src=’./images/delete.png’ style=’border:none;’ alt=’delete’ /></a></td></tr>”;
}
$con .= “</table></form>”;
}
?>

There’s not much going on there other than the mass of ugly looking code. The $v variable is the array of the current user’s details, which is assigned by the foreach loop. Now comes the hard part, well kind of, the JavaScript. After this we’ll be done! :)

File: admin.php (continued)

 

<html>
<head>
<title><?php echo $title; ?></title>
<script src=‘../../scriptaculous/prototype.js’></script>
<script src=‘../../scriptaculous/scriptaculous.js’></script>
<script type=‘text/javascript’>
//Get every new value, taken from our unique IDs assigned earlier.
function edit_user(uid)
{
var opt = {
method:‘post’,
postBody:‘m=edituser&id=’ + uid + ‘&username=’ + $F(‘username_’ + uid) + ‘&email=’ + $F(‘email_’ + uid) + ‘&name=’ + $F(‘name_’ + uid) + ‘&auth=’ + $F(‘auth_’ + uid) +‘&password=<?php echo $user[’password‘]; ?>’,
onSuccess: function(t) { handle_edit(t, uid); }
}
new Ajax.Request(‘./ajax.php’, opt);
}

function handle_edit(t, uid)
{
if(t.responseText == “1″)
{
//Give a pretty notice to say that it was saved
new Effect.Highlight(‘user_’ + uid);
}
else
{
alert(“The user’s data was not updated, please try again.”);
}
}

function delete_user(uid, username)
{
//Confirm the delete
if(confirm(“Are you sure you want to delete “ + username + “?”))
{
var opt = {
method:‘post’,
postBody:‘m=deluser&id=’ + uid + ‘&password=<?php echo $user[’password‘]; ?>’,
onSuccess: function(t) { handle_delete(t, uid); }
}
new Ajax.Request(‘./ajax.php’, opt);
}
}

function handle_delete(t, uid)
{
if(t.responseText == “1″)
{
//Remove the user from the table very nicely :)
new Effect.Fade(‘user_’ + uid);
}
else
{
//Agh!
alert(“The user was not deleted, please try again.”);
}
}
</script>
</head>
<body>
<?php echo $menubar, $con, $footer; ?>
</body>
</html>

You should be familar with making AJAX requests now, you may notice our use of Effect.FadeOut and Effect.Highlight, these are just built in script.aculo.us effects that make UI very pretty. This is it for the tutorial, it’s definitly been a long one. I’ll try to get a working version up soon with public admin access, but I’ll have to modify some code so you guys don’t go to overboard.

A full set of files used in this tutorial can be downloaded here

AJAX with Prototype

(No Ratings Yet)
Loading ... Loading ...

Note: In order to use this tutorial, you need to have the prototype javascript library.

My earlier post on Prototype talked about two of the basic functions, now we’re going to use those functions along with the built-in AJAX functions to make a simple little application. Our application is simply for dummy purposes, but will tell us who has birthdays in certain months. In our script, we will first have to include the Prototype and script.aculo.us libraries; Prototype must be called first!

We will be using the Ajax.Request function which takes a two paramaters, the URL of the handler, and the options. Options specify which method we will be using, the data we send, and what to do when the script completes. All the JavaScript coded by us is a mere 5 lines!

We’re going to setup our table first, which is really simple, just run this query on your database:

CREATE TABLE `birthdays` (`name` varchar(255) NOT NULL DEFAULT ‘’, `age` int(3) NOT NULL DEFAULT ‘0?`day` int(2) NOT NULL DEFAULT ‘0?, `month` int(2) NOT NULL DEFAULT ‘0?) ENGINE=InnoDB DEFAULT CHARSET=latin1

Next, we will code the AJAX handler script which receives a month number, then fetches all birthdays in that month:

mysql_connect(‘localhost’, ‘root’, ‘’);
mysql_select_db(‘tutorials’);
$query = mysql_query(“SELECT `name`, `age`, `day` FROM `birthdays` WHERE `month` = ‘{$_POST[’month’]}’”);
$out = “<ul>”;
if(mysql_num_rows($query) > 0)
{
while($r = mysql_fetch_row($query))
{
$out .= “<li>{$r[0]} turns {$r[1]} on the {$r[2]}</li>”;
}
}
else
{
echo “No birthdays in this month!”;
}
$out .= “</li>”;
echo $out;
?>

This is not complicated code, just a simple SELECT query and a while loop. Now, you may ask how we get the month number? That’s what Prototype sends us through post (you can use get, too). Whatever we echo, Prototype will get and store in the AJAX object as you will see shortly.

Our JavaScript contains one function! It starts and handles the request all at once.

function fetch_birthdays()
{
var month = $F(‘month’);
new Ajax.Request(‘ajax.php’, {method:‘post’, postBody:‘month=’ + month, onSuccess: function(t) { $(‘birthdays’).innerHTML = t.responseText; }});
}

We make use of our $F and $ functions; $F to get the current month from our select (which you’ll see later), and $ to update the div’s contents with the birthdays. Our AJAX request tells that the handler will be ajax.php, the method withh be post, and the data to send is month = whatever the month currently is. The onSuccess part may look weird to you. All we’re really doing is passing our AJAX object as a paramter (Prototype handles this), and then updating our div with the server’s response text, which will be an ordered list with birthdays!

The only part left is creating our form and update div, which is simple:

<h2>Birthdays</h2>
<p>Select a month from the drop down to see whose birthdays are in each month.</p>
<form name=‘months’>
<select id=‘month’>
<option value=‘1?>January</option>
<option value=‘2?>February</option>
<option value=‘3?>March</option>
<option value=‘4?>April</option>
<option value=‘5?>May</option>
<option value=‘6?>June</option>
<option value=‘7?>July</option>
<option value=‘8?>August</option>
<option value=‘9?>September</option>
<option value=‘10?>October</option>
<option value=‘11?>November</option>
<option value=‘12?>December</option>
</select>
<input type=‘button’ value=‘get birthdays’ onclick=“fetch_birthdays();” />
</form>
<div id=‘birthdays’></div>

Our button will call the fetch_birthday function which starts the AJAX request. . .

Making JavaScript Easy With Prototype

(No Ratings Yet)
Loading ... Loading ...

I recently found out about and downloaded a wonderful little package called script.aculo.us, for more information, check out my post on it. I’m going to assume that you have already downloaded script.aculo.us, which includes the Prototype JavaScript framework. The framework contains many functions, but we’re only going to cover two right now. These functions will be $ and $F (weird names, but you’ll find out why soon!)

The first function, $, will make your JavaScript development hundred’s of times faster. Honestly. Now, typing out document.getElementById(’id’) can get rather tiresome pretty quickly. Prototype’s $ function recgonizes this, it does the same thing as document.getElementById, but does it in one character! Here’s an example if you’re still a little confused:

var the_html = $(‘my_div’).innerHTML;

The next function is $F, it’s for forms. All you need to do is give one paramater, that is the input, select, radio button, etc name. $F will return the current value of that field! No more document.form_name.field_name.value, hoorah! Another example in case you’re still in the dark:

Enter your name: <input type=‘text’ id=‘my_name’ /> - <input type=‘button’ onclick=“alert(’Hi’ + $F(’my_name’) + ‘, I\’m Mike!);” value=’say hi!’ />

This is just the basics of Prototype, the rest of it is even cooler!

script.aculo.us

(1 votes, average: 2 out of 5)
Loading ... Loading ...

script.aculo.us is a JavaScript library containing easy to use scripts for drag and drop, visual effects, AJAX, autocompletion, element manipulation, and debug functions. The library requires Prototype (which is the AJAX, element manip. part of script.aculo.us), but it’s shipped with a current version.

The site provides easy to use documentation and examples that will get you started instantly. I’m no JavaScript expert, but I was able to look at the examples, and go from there. Right now, I’m working on a tutorial that uses script.aculo.us to do in place editing, AJAX interaction, etc. It’s the most fun I’ve ever had writing a tutorial, definitly check it out! :)

How to Create Your Own 404 Error Page Using .htaccess

(No Ratings Yet)
Loading ... Loading ...

Alternate Step One: Using .htaccess to Add your 404 Error Page

If you’d rather not muck with the innards of your httpd.conf file, there’s a sensible and less overwhelming alternative solution, at least if you’re using the Apache web server. Instead, create a file in your Web site’s home directory called .htaccess (yes, that’s a dot or period as the first letter. It’s very important!)

You can accomplish this if you have direct edit capabilities on your server, or you can create a file with the correct name on your PC or Macintosh and upload it to the server. Regardless, the content of the file should be exactly:

ErrorDocument 404 /404-error-page.html

In this instance, you’re defining the name of your error page to be exactly 404-error-page.html and that it’s going to live at the topmost directory of your Web site. If you’d prefer a different name, then modify the contents of this file appropriately.

If you use FTP to upload this file to your server, make sure that you transfer it in “text” or “ascii” mode so that it’s properly parsed by the server.

Step Two: Create the 404 Error Page

There are lots of different error 404 pages you can create, ranging from the succinct and dry to the peculiar, to the witty, to the super-helpful (for example, you can easily add a google search for only pages from your site to your 404 error page ).

Whichever path you choose, you’ll find people appreciate if you at least offer a link to your home page and some method whereby they can contact you if they are insistent that certain material should be present but isn’t.

Also, most people agree that not insulting them is a good strategy, but, perhaps surprisingly, this varies and there are definitely some 404 error pages out there that are quite blunt.

It depends on the style of your site, your sense of humor, and whether you want to err on the side of “useful” or on the side of “amusing”.

Step Three: Restart the Web Server

To get the change to the configuration file accepted, you’ll probably need to restart or otherwise nudge your Apache Web server so it knows that you’ve added a custom 404 error page (otherwise it’ll continue to blithly serve up the generic error page instead).

There are a couple of basic commands to accomplish this task:

  1. apachectl is most common,
  2. or you might need to revert to a custom script like restart_apache,
  3. or tools like Webmin have a restart option,
  4. or, if this all seems like too much work, just ask a sysadmin to restart the server.

Regardless of which you choose, it’s always a good idea to also check the log files for the Web server to ensure that everything was accepted and parsed without any errors. On a typical Linux/Unix configuration, the log file would be at

/var/log/messages

because Apache (almost always) is configured to use the standard syslog mechanism.

Step Four: Testing

Once that happens, type in a URL that you know isn’t present on your site and see what happens! If everything is correct, you should see the new 404 error page pop up.

If it doesn’t work, go back to your httpd.conf file, identify where errors are logged (probably an entry ErrorLog) then look in that file to see what’s wrong.

Most likely you have a naming error where it’s called one thing in the configuration file but something else on the actual server.

If everything is working fine, try a second 404 error by requesting a page that’s a few subdirectories into the site, so while for your first test you may have used something like http://www.example.com/badpage this time try something more like http://www.example.com/some/subdir/badpage

If all the graphics are displayed properly and the links to elsewhere on your site are all correct, congratulations! You’ve done it! You’re now the proud owner of a custom 404 error page.

If not, step through this tutorial again, keeping an eye on the error log file, and you should have this figured out in no time.

Adding a Search Box to Your Custom 404 Error Page

(No Ratings Yet)
Loading ... Loading ...

Hopefully you’ve played around with some HTML when you were building your custom 404 error page, as explained in our tutorial on creating your custom 404 error page , in which case this will be a breeze.

If not, it’s time to roll up your sleeves and get ready to do some coding!

Step One: Identifying your 404 error page

The first step is to figure out which page is your custom 404 error page.

Most likely you’ve just built it, so that’s a very simple step, but if not, identify your httpd.conf file, then find the line therein that looks like this:

ErrorDocument 404 /errordoc-404.shtml

That’ll tell you what file is your 404 error page.

Step Two: Open up the file for editing

There are dozens of different Web page and HTML editors on the market, so your process will likely be different to what we use, but hopefully you have a tool like Homesite, BBEdit, or even vi or EMACS to edit the file and can do so directly. If not, you might need to download the HTML file from your server to your local computer then open it with a simple editor like NotePad (on Windows) or TextEdit (on the Macintosh) to proceed.

Step Three: Copy and paste this code

Now the fun part: copy the following lines of HTML and paste them directly into your custom 404 error page:

<form action=”http://www.google.com/search” name=”searchbox”
method=”get” style=”margin-left: 2em;” />
<input type=”hidden” name=”hl” value=”en” />
<input type=”hidden” name=”ie” value=”ISO-8859-1″ />
<input type=”hidden” name=”sitesearch” value=”programimi.com” />
<input maxlength=”256″ size=”40″ name=”q” value=”" />
<input type=”submit” value=”find it” name=”btnG”
style=”font-size:75%;” />
</form>

You need to change the domain name from programimi.com to your own domain, but that’s the only customization required. Save the changes and upload the new version of the file if needed.

Step Four: Testing

Once you’ve saved your new custom 404 error page, generate a page by hitting a link like http://www.example.com/badpage and looking for the form.

That’s all there is to it. You now have a lovely Google search engine that constraints itself automatically to a search of your pages only. Now you should ensure that Google knows about your site and you might also want to fix spelling problems too. :-)

The future of web forms

(No Ratings Yet)
Loading ... Loading ...

Forms, probably the one thing that made the internet popular among the business people. Thanks to this addition to HTML, users are able to interact with a website. Unfortunately, after web forms were first introduced, not a lot has been changed to them. However, with XForms and Web Forms 2.0 on the rise, this is probably going to change. But what are they? What are their new features? And more importantly, which one is going to be superior?

XForms

Lets start with the oldest technology: XForms. XForms 1.0 became a recommendation in late 2003 and an update, XForms 1.1, is already in development. One of the biggest advantages is that XForms is an XML namespace and can therefore be used in a lot of ways as a completely device-independant application. To understand what this means, take a look and/or read the introduction on XForms.

Now that I did my duty to give you a short introduction to XForms, lets take a look at its interesting parts: its features. XForms are always seperated into two 2 parts:

  1. the XForm Model;
  2. and the XForm UI.

The XForm Model is used to describe the form’s data and how to submit it, while the XForm UI is used to make the form available to the user. How the XForms UI should look is not described by the XForms specification in any way, so it’s up to the user agent to render the form in the most usable way. Because of this, it makes XForms very flexible and usable for the user.

First, lets take a look at the XForm Model. This is always defined in the model element. The model can take 3 different child elements:

  • instance;
  • submittion;
  • and bind.

The instance element describes all the data which is to be gathered. Every piece of data gets its own element inside the instance.

The submittion element(s) describe(s) how and where to submit the data. Multiple submittion elements can be added to the model which make it possible to submit data to different servers, or using a different HTTP method. For instance, you can have 2 buttons in your form. One to save the data as a file on the server, and one to submit the data to a form which saves it in a database.

The bind element is where the actual fun begins. Using this element you can create a relation between elements. For instance, using a bind element you can specify that a certain element may only be enabled if the value of another element matches a predefined value. So if you have a form that can be used to pay for something, you can ask the user how he/she would like to pay. This could be either by Paypal, cash or credit card. In this case you can specify only to enable the input field where the user can enter the expiration date if the user selects credit card to be the payment method.

But bind also has other features. Take the type attribute for example. This attribute tells the user agent what data is allowed. Combine this with XML Schema, and you have a very powerful way of specifying what kind of data is allowed. This can vary between strings or integers, but also dates or URIs. If these are not enough, you can of course create your own schema with XML Schema for total control.

Another feature of bind is to calculate an outcome. For instance the combined value of two numbers that the user has entered, or an average, etc. The outcome of this calculation can be displayed on the page without even submitting the form data or using scripting.

Below is a small example of how a model could look like:

<model xmlns="http://www.w3.org/2002/xforms"
       xsd:xmlns="http://www.w3.org/2001/XMLSchema"
       my:xmlns="http://jero.net/lab/xml/ns">
 <instance>
  <my:to/>
  <my:amount/>
  <my:details/>
 </instance>

 <submittion action="pay-me-now.php" method="post" id="pay"/>
 <bind nodeset="to" type="xsd:string"/>
 <bind nodeset="amount" type="xsd:integer"/>
</model>

Because there’s no such thing as stand-alone XForm documents, the model element in the example above would normally be placed inside the xhtml:head element.

Now that we have taken a quick look at the XForm Model, lets take a look at the UI. As I said earlier in this article, XForms does not, unlike HTML, specify how the form controls should look, but what they do. That’s a major difference here, so make sure you understand that. Once you’ve got that pumped into your brain, let’s take a look at XForm’s form control elements. I will compare them with HTML’s controls to make it as easy a possible for you to understand them (isn’t that nice?). But to avoid confusion, I will refer to XForm elements as xform:element and html:element for HTML elements. If no namespace is present, you can asume that the element is part of the XForms namespace.

The input element
Just like HTML, XForms also has this element. However, unlike html:input element, you do not need to specify the kind of form control (input field, password, radio button etc.) because xform:input is only suitable for text. So xform:input will probably render as <html:input type="text">. All other purposes that html:input has are divided into other element which are described below.
The secret element
Unlike you might think, this is not the equavalent of <html:input type="hidden">, but instead it is the equavalent of <html:input type="password">.
The textarea element
Same as html:textarea. However, the cols and rows attributes are not required in XForms (as a matter of fact, they don’t even exist). For visual user agents, you can specify the dimension using CSS.
The output element
As I said earlier in this atricle, you can use the bind element in the XForm Model to calculate something and display it on the page. Together with the ref element we can refer to a bind element to show the outcome of the bind’s calculation.
The upload element
Same as <html:input type="file">.
The range element
This element is something we’ve never seen before on the internet besides in Flash applications. With this element you can specify a value in a certain range. So if you want to let the user choose between the numbers -10 and 10, you could of course use the xform:input element to let the user type the number in for himself. But with the range element you can make it the user easier to select the correct value in the range specified by the min and max attributes.. Accessibility++! However, this is of course nothing new. Just take a look at your volume control.
The trigger element
Same as <html:button> and <html:input type="button">.
The submit element
Same as <html:input type="submit"> and <html:button type="submit">.
The select and select1 element
What!? A number in an element name!? Yes, a number! And you better not mess with it because xform:select and select1 are pretty darn useful. These two elements are not only the equivalents of html:select, but also for checkboxes and radio buttons. All you need to do is put the available options inside the xform:select or select1 and let the user agent decide how it should look. This can be a list of checkboxes/radio buttons, drop-down list, or whatever the user agent think it’s best for the user.The difference between the two elements is that with select1 the user can only choose one value, while the user can select multiple options from xform:select elements.

To give you an example of how an XForm UI may look like, take a look at the possible UI for the model we created earlier:

<group xmlns="http://www.w3.org/2002/xforms">
 <label>Transfer Money</label>
 <input ref="to">
  <label>Receiver</label>
 </input>

 <input ref="amount">
  <label>Amount</label>
 </input>

 <textarea ref="details">
  <label>Additional details</label>
 </textarea>

 <submit submission="pay">
  <label>Transfer!</label>
 </submit>
</group>

As you see, the group element is used to group all the payment controls. In HTML we’d normally use fieldset for this. The xform:label inside the group can be compared with html:legend as they both act as a title for the group/fieldset. The xform:labels inside the xform:input elements are used as text to describe the xform:input element. This is comparable to the function of html:label. The xform:label inside the submit element will probably be rendered as text on a button, just how <html:button>Submit!</html:button> would be rendered.

Web Forms 2.0

Now that I gave you some info about XForms (yes, only some as there is a lot more), lets take a look at XForms’s younger stepbrother: Web Forms 2.0 (WF2). WF2 is developed by the WHATWG which is the same group who’s developing the Web Applications 1.0 specification, aimed at extending current markup languages (HTML 4.01 and XHTML 1.0). The same applies to WF2. Unlike XForms, WF2 does not want to replace current web forms. Intead, WF2 aims at extending current web forms which has one very important advantage: backwards compatibility.

When you’d read the Web Forms 2.0 specification, you’d be delighted with the fact that because of WF2’s backwards compatibility it is very easy to pick up, especially compared to XForms which is basically a pain the ass to learn. Just take a look at the INPUT element. Yes! Exactly the same as HTML 4.01’s INPUT element, although with new values for the type attribute:

datetime, datetime-local, date, month, week and time
These new values tell the user agent that only values that are encoded as defined in ISO 8601 (dates like 1996-01-01T00:00Z). When a WF2 confirming user agent would see an INPUT with either of these values for the type attribute, it could make it the user easy and display the input field as Windows' date selector. This way the user agent can make sure that the submitted date will always confirm to ISO 8601 and the user will have less problems with entering the date (some sites require a specific scheme like MM-DD-YYYY which would cause trouble for European users because they’re used to DD-MM-YYYY).
number
The INPUT will only allow numbers. No explanation needed I hope…
range
Ah, one of the new elements in XForms also found its way into WF2. Just like xform:range, the html:input with the value range for type will allow the user to select a value in the range of the numbers specified by the min and max attributes.
email
Once again, I think this input type would cause no problem understanding.
url
Same here…

If you still don’t like the new values for type, you can write your own regular expression that should be used to validate the user input. This regex can be included in the pattern attribute which will be used to validate the user’s input upon submission.

Of course, the additions to WF2 do not limit themselves to input types. Take the required attribute for example. If there is a form control forgotten that has the required attribute, the user agent should not submit the data. The same applies to the type and pattern attributes if a value is submitted that does not meet its field type.

Another new element we see in WF2 is the DATALIST element. This element allows the author to specify a list of default values for, for instance, a text field which will have a somewhat similar effect as your browser’s address bar. Once you click on the arrow at the right of it, a list of IRIs which you previously visited appear. You can think of the DATALIST element to contain such a list of options which can be selected by the user in the INPUT is he wishes to do so.

And I could go on and on and on about all the new features in both specifications. I didn’t even talk about Web Forms 2.0’s repetition model, XForms’s Repeat Module and the new events! However, doing all this research on these two forms did made me understand the two a lot more. Not only did I learn about the new stuff they bring, but also that it’s not 100% fair to compare the two with each other. First of all, the Web Forms 2.0 is still a Working Draft while XForms 1.0 is already a W3C Recommendation since October 2003. The WF2 specification also says that Web Forms 2.0 aims to simplify the task of transforming XForms 1.0 systems into documents that can be rendered on HTML Web browsers that do not support XForms. Therefore we can’t really talk about two competing standards.

However, I think it’s clear that both are at least much, much better than the forms we have now. XForms of course being the more powerful of the two. Its power is incredible thanks to the powerful XML functions that allow the use of multiple namespaces in the same document. However, due to the lack of native support for XForms (only Firefox 1.5+) and XML in general (Internet Explorer), it’s going to take a long time until we can use this awesome namespace.

And that’s the sole reason why WF2 was born: because we have to wait for such a damn long time. Thanks to WF2’s backwards compatibility, we can use most of XForms’ features without discriminating legacy browsers like Internet Explorer because WF2 support is not needed to complete the form. The only advantage that WF2 adds is the fact that forms become a lot more usable for the user when the user’s browser supports WF2. Hopefully modern browsers like Firefox, Opera and Safari can use WF2 to win more users.

However, in the long run, I don’t see WF2 surviving. I still think XForms is a lot better, and once it gets proper support, I’m sure we can say goodbye to WF2. Now don’t get me wrong on this. I still think that WF2 is a great extension to current web forms until the browsers ship with native XForms support and I can’t wait for Firefox to support it.

Seperating style from structure

(No Ratings Yet)
Loading ... Loading ...

As we all know, the table element shouldn’t be used for styling your document. The div element should be used instead, together with the id and class attribute to style it with CSS, just like the HTML 4.01 and XHTML 1.0 specs tells us to do. But aren’t we polluting our markup with these div elements, because we’re only using them for presentational purposes?

First, let’s take a look at an example. Here’s the HTML code of the top of previous layout:

<div id="logo">
 <h1>Programimi.com</h1>
 <hr>
</div>

As you see, I wrapped the site name and a hr element inside a div element. But the div element has absolutely no purpose in my document instead of having the id attribute and using CSS to style it. So by using divs, you don’t separate presentation from structure at all, nor does it have any semantic value, just like the font and center elements.

One might argue that the div element can be used to divide the document into sections. If this were true, the div would have a real purpose. Unfortunately, it isn’t. Just take a look at what the HTML 4.01 specification says about the element:

The div and span elements, in conjunction with the id and class attributes, offer a generic mechanism for adding structure to documents. These elements define content to be inline (span) or block-level (div) but impose no other presentational idioms on the content. Thus, authors may use these elements in conjunction with style sheets, the lang attribute,etc., to tailor HTML to their own needs and tastes.

Ok, the spec does talk about adding structure, but that’s actually quite vague, don’t you think? What kind of structure do they mean!? Because the W3C didn’t give any real information on how the div element can give structure to a document that can also be understood by user agents, “adding structure” is actually not possible because no-one understands how it is structurized. The only possible way to do so is by using the id attrubute, but the value of this attribute can only be understood by humans, not user agents. Therefore, it’s still impossible to give structure to a document by using the div element so the only reason to use the element is to group certain elements together in order to style them (or give it a lang like the quoted piece from the HTML 4.01 spec says, but who uses the attribute anyway!?).

So should we just ditch the div element? I guess not. You should, but it would be impossible to make a decent layout at the moment. Which I, as a web designer, enjoy looking at. Another reason would be because we don’t have any alternatives. Well, not yet. Just take a look at the header element, introduced by HTML, or XHTML 2’s role attribute. By using either one of the methods instead of the div element from my previous example at the beginning of this article, that section will actually have a meaning. In other words, the document will become semantically richer.

Using the .htaccess file

(No Ratings Yet)
Loading ... Loading ...

If you have a website, it is most likely that your server is using Apache as its web server software. Apache has a nice feature that provides the ability to customize configuration directives defined in the main configuration file using a file called .htaccess. In this article I’d like to discuss how you can use the .htaccess file to pimp up your website.

Mod_rewrite

Lets start with my personal favorite: mod_rewrite. It’s an extension module that allows you to mask URIs. An example: I have the URI http://domain.com/contact to point to my contact form, but there’s no file called contact. The URI to my contact form points to an ugly WordPress generated URI with some PHP variables. This can be done with the following configuration:

RewriteEngine On

RewriteRule ^contact/?$ /wordpress/index.php?name=$1

Many also use mod_rewrite to redirect anyone who accesses their website with the www subdomain to the bare domain name, because the www subdomain is just pointless as described on no-www.org. Here’s the configuration for .htaccess to achieve this effect (this code can also be found at no-www.org):

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]

RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]

If you’d like to learn more about this module, do to Apache’s documentation about mod_rewrite.

gzip

Using this is absolutely a must. You can allow the server to compress the HTML using gzip and send it to the browser (if it supports gzip, unlike IE). The browser receives it, decompresses it and shows the page like it would normally do. This will definitely reduce your bandwidth. The front page of this website was around the 10KB before I used gzip to compress my pages, and now it is around 3,50KB. mozilla.org has a nice page for a more detailed description about gzip compression. Here???s the configuration to use gzip compression for your HTML files: (Yes, it’s just one line.)

php_value output_handler ob_gzhandler

The AddDefaultCharset directive

How does a user agent know which character encoding has been used? The server should provide this information. The most straightforward way for a server to inform the user agent about the character encoding of the document is to use the “charset” parameter of the “Content-Type” header field of the HTTP protocol ([RFC2616], sections 3.4 and 14.17).

That’s what the HTML 4.01 Specification tells us about defining the character encoding. Yet, many people still use the meta element for this purpose. The meta element also sends an HTTP header, but when the browser parses the document, it has to guess character encoding to parse the beginning of the document because the character encoding is only defined later on, in the head element. So it\ s much better to configure your server to send the HTTP header before the file is being parsed. You can use the .htaccess file for this as well, with the AddDefaultCharset directive. The configuration below configures the server to send all documents with the UTF-8 encoding:

AddDefaultCharset utf-8

Learn more about the AddDefaultCharset directive.

The ErrorDocument directive

I guess this is probably the most well known directive, but I’d like to put it in this article anyway. With this directive you can specify what file should be shown when a certain HTTP Status Code has been sent. So if a user agent tries to access a file on a server that does not exist, the server responds with the 404 Status Code. You can use the ErrorDocument directive to show a custom error page instead of Apache’s boring default page. Here’s an example configuration to define a custom error page for when a 404 error code has been sent:

ErrorDocument 404 /error-docs/404.html

Get more info about the ErrorDocument directive.

Those were the directives I currently use in my .htaccess file. But of course, there are a lot more. Most of them are explained at the page Apache Core Features. If you have any other .htaccess tricks that you find very useful, feel free to post them.