It was a long time since my last post, so I thought of posting something interesting today: A tutorial that will show you how to use AJAX with Jquery to call PHP scripts. Take a coffee, it’ll be a long read ;) You may want to check what we are going to build before diving into this tut.

  1. Designing the form
  2. First step is to design a nice looking form. The form has 3 inputs: Two text boxes and one button. We can either user tables or lists. But I prefer to use lists and labels since they are SEO friendly.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Ajax Web Form</title>
    <link href="style.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <div id="wrap">
    <form id="ajaxform">
    <div class="form_description">
    <h2>Ajax Web Form</h2>
    <p>
    This is an example Ajax form. It checks if the username is available or create a new username.
    </p>
    </div>
    <ul>
    <li id="username_check">
    <label class="lbl">
    User Name (Availibility)
    </label>
    <div>
    <input class="txt_input" id="txt_checkuser" type="text" maxlength="255" value=""/><p class="hint"> <img src="img/ok.png" /> User name Available</p><p class="hint"><img src="img/no.png" /> User name already used</p>
    </div>
    </li>
    <li id="username_add">
    <label class="lbl">
    Add UserName
    </label>
    <div>
    <input class="txt_input" id="txt_adduser" type="text" maxlength="255" value=""/>
    <p class="hint"> <img src="img/ok.png" /> User name added successfully</p><p class="hint"><img src="img/no.png" /> Error while adding User name</p>
    </div>
    </li>
    <li class="buttons">
    <input id="submit_form" class="btn" type="submit" value="ADD" />
    </li>
    </ul>
    </form>
    </div>
    </body>
    </html>

    Now let’s add some CSS code to make it look a little better and more inducing.

    #wrap
    {
    width: 550px;
    height: 250px;
    margin: 75px auto;
    }
    .btn
    {
    float: right;
    width: 150px;
    height: 35px;
    border: 1px solid #000004;
    background-color: #A8CBFE;
    cursor: pointer;
    }
    BODY
    {
    margin: 0;
    font-family: "Lucida Grande", Tahoma, Arial, Verdana, sans-serif;
    font-size: small;
    padding: 0;
    }
    H2
    {
    clear: left;
    font-size: 160%;
    font-weight: 400;
    margin: 0 0 3px;
    }
    #ajaxform
    {
    padding: 10px 25px 50px;
    border-top: 40px solid #A8CBFE;
    margin: 0;
    border-left: 1px solid #B9B9C5;
    border-bottom: 1px solid #B9B9C5;
    border-right: 1px solid #B9B9C5;
    }
    .form_description
    {
    border-bottom: 1px dotted #999999;
    margin: 0;
    padding: 0;
    }
    FORM LI
    {
    display: block;
    margin: 0;
    padding: 4px 5px 2px 9px;
    position: relative;
    }
    #username_add:hover
    {
    background-color: #DAFCBF;
    }
    #username_check:hover
    {
    background-color: #DAFCBF;
    }
    #username_check
    {
    }
    FORM UL
    {
    font-size: 100%;
    list-style-type: none;
    margin: 0;
    padding: 0;
    width: 100%;
    }
    .btn:hover
    {
    background-color: #A9DAFD;
    }

    Our form should look like this (Oh, for the icons they are the famous FAMFAMFAM icons :) )

    You should have noticed the hints. They are visible since we are going to hide/show them using Jquery.
    So we’ll add some additional code to load the library and hide the hints.
    Add this code to the “head” of the page. Don’t forget to download Jquery, I used version 1.3.2 as of the release of this tutorial.

    <script src="jquery.js" type="text/javascript"></script>
    <script src="script.js" type="text/javascript"></script>

    After, create a new javascript file called “script.js” and add the following code. It’ll hide the hints when the page loads.

    $(document).ready(function() {
    // Hide all the hints
    $('.hint').hide();
    });

    Later on, you’ll discover that we’ll load the hints from the PHP script using Jquery. Nevertheless, we’ll need a hint stored on HTML in case AJAX can’t connect to the server.

  3. The database and the PHP code
  4. Next we need to set up a database and a table to store the user names. I named my data base “mydatabase” and the table “users”. Here’s the SQL code to generate the table. It’ll create two rows.

    -- phpMyAdmin SQL Dump
    -- version 3.2.1
    -- http://www.phpmyadmin.net
    --
    -- Host: localhost
    -- Generation Time: Aug 18, 2009 at 08:13 AM
    -- Server version: 5.1.37
    -- PHP Version: 5.3.0

    SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

    --
    -- Database: `mydatabase`
    --

    -- --------------------------------------------------------

    --
    -- Table structure for table `users`
    --

    CREATE TABLE IF NOT EXISTS `users` (
    `ID` int(4) unsigned NOT NULL AUTO_INCREMENT,
    `username` text NOT NULL,
    PRIMARY KEY (`ID`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ;

    --
    -- Dumping data for table `users`
    --

    INSERT INTO `users` (`ID`, `username`) VALUES
    ('omarabid'),
    ('anotheruser');

    In order for the query to work correctly, log in to PHPmyadmin, select a database and then click “SQL” tab. Paste the code and hit the “Go” button.

    Now we need to create a PHP script. It will be called later using Jquery. We’ll use the OOP methodology. So we’ll create a user class and two function “checkuser” and “adduser” that return either true or false.
    The user Class

    // User Class
    class user {

    var $_un;
    function user($un) {
    $this->_un = $un;
    }
    function adduser() {
    // Checks if user exists
    if ($this->checkuser() == true) {
    return false;
    } else {
    // Try to add the user
    $qr = mysql_query("INSERT INTO users (username) VALUES( '".$this->_un."' ) ");
    // Return True or False
    if ($qr == 1) {
    return true;
    } else {
    return false;
    }
    }
    }
    function checkuser() {
    // Query the DB
    $qr = mysql_query("SELECT username FROM users WHERE username = '".$this->_un."'");
    $res = mysql_fetch_array($qr);

    if ($res == NULL) {
    return false;
    } else {
    return true;
    }
    }

    }

    The PHP script
    The script is composed of three parts: The Class, the Mysql Connection and the code (that will execute the transactions).
    In the top, we’ll place the user class. Next, we’ll connect to the database. After, we’ll grab HTTP post information and execute actions from them.

    // Add the user class here
    // Disable caching to prevent unwaited results
    header("Cache-Control: no-cache");

    // Connect to Mysql
    $conn = mysql_connect('localhost', 'root', 'your-password') or die('Could not connect to mysql');
    mysql_select_db('mydatabase') or die('Could not connect to DB');

    // Retrieve data from HTTP Post
    $action = $_GET['action'];
    $username = $_GET['username'];

    // Create a new user object
    $newuser = new user($username);

    // Parse HTTP header information

    if ($action == 'add') {
    if ($newuser->adduser()) {
    // User Added
    echo '<p class="hint"> <img src="img/ok.png" /> User name added successfully</p>';
    } else {
    echo '<p class="hint"> <img src="img/no.png" /> User name was not added</p>';
    }
    } elseif ($action == 'check') {
    if ($newuser->checkuser()) {
    // User Already exists
    echo '<p class="hint"> <img src="img/no.png" /> User name already exists</p>';
    } else {
    echo '<p class="hint"> <img src="img/ok.png" /> User name available</p>';
    }
    } else {
    echo "No Action Is defined";
    }

    // Close Connection
    mysql_close($conn);

    To make the script work, you need first PHP and Mysql running either on a host or on your local machine.
    After, create a Mysql database and add the “users” table to it (as described above).
    Now, it’s time to tweak the script. Change the host, username, password and database values. Next, place the script in your host root or a folder and execute it. If nothing “No Action Is defined” shows, then the connection worked correctly.
    To try the script and check if it functions correctly, type “script.php?action=check&username=typehere”.

  5. Ajax Calls
  6. It’s time we implemented the AJAX feature. We have two inputs to check: The first one after the user completes typing, the next when the user clicks the “Add” button.

    $(document).ready(function(){
    // Disable caching to prevent unwaited results
    $.ajaxSetup({
    cache: false
    });

    // Check un availability after typing a name
    $("#txt_checkuser").change(function(){
    // Store the username in a variable
    var jq_username = $("#txt_checkuser").val();
    // Prepare the link
    var link = 'http://localhost/AJAX/user.php';
    $('div #checkuser_hint').load(link, "action=check&username=" + jq_username);
    });

    // Add a user name
    $("#submit_form").click(function(){
    // Store the username in a variable
    var jq_username = $("#txt_adduser").val();
    // Prepare the link
    var link = 'http://localhost/AJAX/user.php';
    $('div #adduser_hint').load(link, "action=add&username=" + jq_username);
    });
    });

    As you see, first we disabled the cache. Second, we bind the change event to the txt_checkuser input. This will make the code run when the user change focus from the input. Third, we bind the button to the click event.
    Now everything is working correctly and as it should.

  7. Optimization and security
  8. Security
    The script and form works, but we didn’t take care of malicious people and hackers in the web. We need to secure our form against SQL injections.
    If you are new to them, here’s a simple example.
    This code queries the database using the variables directly.

    // Query database to login any matching user
    $query = "SELECT * FROM users WHERE user='{$_GET['username']}' AND password='{$_GET['password']}'";
    mysql_query($query);

    ?>

    Now, let suppose someone entered the following.
    Username: topuser
    Password: ' OR ''='
    The mysql query will become
    $query = “SELECT * FROM users WHERE user=’topuser’ AND password='' OR ''=''”
    Resulting in full access to any accout!
    To prevent SQL injection, PHP offers a function called “mysql_real_escape_string”. Here’s how we can implement it.


    // First query
    $qr = mysql_query(sprintf("INSERT INTO users (username) VALUES( '%s' ) ",mysql_real_escape_string($this->_un)));
    // Second query
    $qr = mysql_query(sprintf("SELECT username FROM users WHERE username = '%s' ",mysql_real_escape_string($this->_un)));

    Optimization
    We can optimize our form a little bit. We can for example check for user input, server availability or any other thing.
    For example, while I was trying it; I noticed that when I check for an available username and then add it, the available notice don’t change to unavailable even if you edit the username and retype it.

    As you see, the “User name available” doesn’t change since text didn’t changed. So Jquery don’t fire the function another time.
    To fix this little issue, we can add this conditional block when the user hit the add button

    // If the username is the same as checked, change the notice
    if (jq_username == $("#txt_checkuser").val()) {
    var link = 'http://localhost/AJAX/user.php';
    $('div #checkuser_hint').load(link, "action=check&username=" + jq_username);
    }

    We can never finish optimizing and securing our scripts and code; but we try to do our best ;)

  9. The End
  10. In this tutorial, you learned how to create a simple web form, write PHP code to query a database and use AJAX with Jquery to dynamically link between the form and the script.
    I tried to explain Step-By-Step, I also made an online example available for preview; you can also download the source code.
    Now let me hear critics, suggestions, bugs....

{ 0 comments }

5 tips to write better CSS

by Omar Abid on August 12, 2009 · 0 comments

in Web Development

CSS is an easy to learn and use language, but working with it in real world problems can be a little challenging especially for newbie. The main cause of trouble is different browser support and rendering for CSS.

  1. Tip 1: Learn how to target IE
  2. IE is known for its’ bad support for the CSS and HTML standards, however 60% of people use it. So it needs a special care which means a special style sheet for it.
    In your page “head”, you can target IE browsers by this tag


    <!--[if IE]>
    <link rel="stylesheet" href="ie.css" type="text/css" />
    <![endif]-->

    Nevertheless, this doesn’t always work. Why? Because IE6 and IE7 are also different, so you need to target each one apart.
    Target Version 6 only:


    <!--[if IE 6]>
    <link rel="stylesheet" href="ie6.css" type="text/css" />
    <![endif]-->

    If you have tweaks for earlier versions of IE, don’t target each one alone, you can target less than IE X


    <!--[if lt IE 7]>
    <link rel="stylesheet" href="ie6.css" type="text/css" />
    <![endif]-->

    And more than IE X


    <!--[if gte IE 7]>
    <link rel="stylesheet" href="ie7.css" type="text/css" />
    <![endif]-->

  3. Tip 2: Use a CSS reset
  4. Browsers have default values for margin, padding. But each browser has its’ default settings.

    To avoid being confused (especially when using margin and padding values), you’d better use a reset to set all values to default.

    Some Popular CSS resets:
    MeyerWeb
    YUI CSS reset

  5. Tip 3: Make your content printable
  6. What about if a user liked a page and desired to print it and read it offline instead?
    Will it print all those widgets, logos and other carps you did add to your website?

    CSS is flexible and offers a way to target other media than screen, like print, phones…

    To include the style in a style sheet:


    @import url("fancyfonts.css") screen;
    @media print {
    /* style sheet for print goes here */
    }

    In a HTML page


    <LINK REL="stylesheet" TYPE="text/css" MEDIA="print, handheld" HREF="foo.css">

    For more information, visit W3C

  7. Tip 4: Use an advanced CSS editor
  8. Get yourself advanced CSS editors and some other professional plug-in.
    Most popular and powerful ones are
    FireBug
    Firebug: a Firefox plug-in for debugging HTML, CSS and JavaScript.
    Stylizer
    Stylizer: not very popular but you are very unlikely to try another if you explored all its’ functionalities.

  9. Tip 5: Compress Vs. lucid your code
  10. When writing, reading and debugging CSS, it’s better to use understandable code, like this.


    Body
    {
    Color: #121212;
    }

    When publishing your website, compressing your code can save you few bits (by suppressing spaces, comments…): up to 40%.


    Body { color: #121212; }

    Clean CSS is a great service that can both compress and uncompress your code.

     

Interested in more tips to improve your coding skills?

53 CSS techniques (Smashing Magazine)
CSS tips and tricks (Blog Herald)
101 CSS techniques (Noupe)

{ 0 comments }

Creating a subscribe button with CSS

by Omar Abid on August 10, 2009 · 1 comment

in Web Development

Yesterday I sit down and began tweaking this website. I have a lot of time; but I’m very lazy to finish it in one day. So like always I spend more time than I should.
I started with the side bar; as you see at top I wanted to add a subscribe button. But this wasn’t as easy as I thought and this took a very long time.
To save time and efforts, I used an advanced CSS editors called “Stylizer“, it’s great and allows real time modifications.
To begin, let’s create a division where we’ll put our subscription link.


#rssfeed
{
width: 150px;
margin: 0 10px 0 0;
padding: 0;
height: 45px;
}

The subscribe link will be associated with a picture (for awesomeness); I thought the picture would better change when user hover the link.
This is not easy as it sounds, in the past used to use lists which makes it more easier, but now I have to use a “p” tag.


#rssfeed P
{
padding: 0 0 0 35px;
background-image: url(http://codeinput.com/images/rssfeeds.png);
background-repeat: no-repeat;
cursor: pointer;
margin: 0;
height: 45px;
}

Everything is perfect now (if you are offline of course!), still I need to style the link, since the subscribe button is a link. I thought of styling the link when not hovered and to change its’ color when hovered.
And here there’s another problem, you can’t use “a:hover” property, because the link color won’t change only if you hover the link. (If you have the “P” the picture will change but the link won’t). So here’s a trick to make them works together.


#rssfeed P:hover
{
background-image: url(http://codeinput.com/images/rssfeedshover.png);
}

Instead of using A:hover we use P:hover and change the A color. It works well!
Time to try the new button online. It works like it should but… it hangs a little when you hover it the first time. It seems that the second picture is not loaded automatically; so let’s do something.


#rssfeed P A
{
text-decoration: none;
color: #595959;
font-family: Georgia;
font-size: 16pt;
font-weight: bold;
}
#rssfeed P:hover A
{
color: #020202;
}

I browsed the Internet, there are few methods that can be applied. One is to create one image and slice it with CSS. The other is to load the image with Jquery.
Slicing is hard: I need to create one image and then slice with CSS.
Jquery is good: But I need to load the framework, add code, check with Firefox and I’m very lazy. So I come up with my own solution.
Let’s create a division, it’ll load the second image
Now in CSS, we are going to hide it, you can also place it absolutely so it doesn’t bother your template. For me, I just placed in the bottom (the easiet solution).


/** CSS Code **/
.imgload {
visibility:hidden;
}
/** HTML Code **/
<div class="imgload">
<img src="http://codeinput.com/images/rssfeedshover.png" alt="" />
</div>

Okay, now it’s working correctly (I’m using IE8 with Windows 7). Let me hear your suggestions.

{ 1 comment }

How to be successful and make it!

by Omar Abid on August 2, 2009 · 8 comments

in Self Developement

Today I read this discussion in Hacker News. I thought it would be interesting to write about this topic.

When I started this blog, I hadn’t much money to order a customized template. So I went for a free one, as this free template compete with the paid ones in ThemeForest.

Few days ago, I read some interviews with successful bloggers and wondered how they made such great blogs.

I took two examples and analyzed them deeply. I found that they have the same startegy, the same starting… and nearly the same ending result.

The first blog is Coding Horror. The blogger is Jeff At Wood and you should already know him.

Coding Horror Template

A very simple template; made exactly for web readability. So is the secret hidden in this template?

Let look at the other example, may be only few of you knows it. Dosh Dosh, an Internet Marketing blog written by a student MakiMaki.

The blog isn’t as successful as coding horror, but more than 30K of readers are already an achievement. A great achievement, especially the blog had started in 2007 and not in 2004.

Again a very simple template and made for web readability. So is the secret hidden in this simple, clean and typographic template?

No, the blog template is a factor. No one will like a crappy blog with dozen of advertisements and pop-ups. But this is not the secret to success.

In “How To Achieve Ultimate Blog Success In One Easy Step“, Jeff At Wood states how he made a successful blog and the one easy (yet very long) step.

When people ask me for advice on blogging, I always respond with yet another form of the same advice: pick a schedule you can live with, and stick to it. Until you do that, none of the other advice I could give you will matter. I don’t care if you suck at writing. I don’t care if nobody reads your blog. I don’t care if you have nothing interesting to say. If you can demonstrate a willingness to write, and a desire to keep continually improving your writing, you will eventually be successful.

So Jeff assumes that any persons can start blogging with zero knowledge in blogging? Absolutely! I browsed the archive and found those little posts.

In fact, Jeff At wood first posts were short, simple and even you can write similar if not better than them. You can browse those posts by adding +1 each time, for example here’s the first post
http://www.codinghorror.com/blog/archives/000004.html
the next will be
http://www.codinghorror.com/blog/archives/000005.html
Or just use Jeff browsing links.

Dosh Dosh is no better, its’ first posts can be found here. They are no perfect from my blog posts in Web nudge. However his latest posts are way far from my current post. I started blogging in 2007 in a free Blogger blog (I sold it later), then moved to web nudge last year and here I’m starting again.

If I regret something now, is that I didn’t stick to my first blog. I made around 50 subscriber in the first one, 170 in the second and here there are already 10. I thought that moving to another blog, will dismiss the past and create a new future, better one.

But no, that was completely wrong and a waste of time.

So lesson learned: Stick to your blog, to your project, fight to the end. Never give up. The successful person is the patient one, that learn from his mistakes and try to correct them instead of starting something new.

{ 8 comments }

If there’s something in which FireFox stand out against all its competitors it’s: Plug-ins.
And not only supporting Plug-ins; but also the rich library and set of advanced tools built for it.

Those extensions are not only for developers, it exists thousands helpful for casual surfer, social media addicts, SEO and websites optimizers and surely hackers!

Most of the time, I use Chrome for surfing (because it’s fast and flexible) and FireFox to debug templates and JavaScript Code. IE 8 is to test my templates and scripts, so I ensure compatibility over that browser.

FireFox extensions happen to solve the hardest part: Tweaking and debugging. To do so, I use an advanced set of extensions; which increase productivity and speed up things.

  1. FireBug
    The unbeatable extension for debugging HTML, CSS and Java Script! Firebug is not only for FireFox, but also comes with a light version for Internet Explorer which simplify the compatibility task with it.
    Why Firebug?
    It comes with a complete suite for debugging and tweaking. Here are the features I use most.

    • Inspect: The inspect feature is the most exciting one, by clicking the “inspect” button, you can hover your mouse over any Div, URL or object and Firebug will display its’ settings and position in the DOC.
      FireBug_Inspect
    • Layout: Even this function is beneath the Inspect feature, I want a special highlight for it. The layout functions, allows you to dynamically change the borders, padding and margins sizes. Simply after selecting an element, change the values in the boxes and watch the effects.
      FireBug_layout
    • JavaScript Console: The JavaScript Console is a simple interpreter that executes JavaScript Code on your page.
      This console is very useful when you are dealing with a framework functions like Jquery. You don’t need to edit the page, save it and reload it, click the link to test if the animation works or not. With the console, you’ll simply type those lines of code and run them live!
      FireBug_Console
    • Firebug is full of features and functions, those aren’t the most important, but the most I use in debugging code and tweaking templates. FireBug also has the ability to debug Js code and step through it. Download FireBug.

  2. Web Developer Toolbar
  3. Is Firebug sufficient? I can say ‘yes’, but it’s not perfect. Here come some simple tools that can speed things more like Web Developer toolbar. The toolbar have nothing in special, rather being an enormous shortcut to a large row of functionalities.
    I can delete cookies using FireFox ‘Options’ box, I can disable CSS by removing the link to the CSS sheet and reloading the page, but doing it takes a few seconds. The toolbar makes it instantly with its simple shortcuts.

    WebDeveloperToolBar
    Another functionality I consider important within this extension is the code source editor. It allows dynamic modification of source code. Note that also Firebug has a similar function, but different in implementation. Web developer HTML editor is a simple Notepad with a search text box; however Firebug editor is a hierarchic list where you can edit items. Both ways has advantages and depending on your current tasks, one way is better than the other.  Install WebDeveloper Toolbar

    WebDeveloperToolBar

  4. FireFTP
  5. My favorite FTP client of all the time is ‘FileZilla’. It’s simple, easy and includes the features I need to get my files to the server. Fireftp is not a competitor; it’s a light version of FileZilla and hand out to be a fast shortcut. I use it to edit a single page to fix a bug, it’s fast and simple. It also comes with the elementary needed functionalities. Install FireFTP.

    FireFTP

  6. ColorZilla
  7. Imagine you are tweaking a template for a client. He asks to fix few size bugs and also to change its disgusting colors. You would use firebug to do that. You’ll inspect its’ elements and resize them, test on IE… For the colors, you need to change them to something nicer, but HTML don’t understand “RED”, “BLACK”… so you put the code, but how to get the code?

    I didn’t write this long introduction for a simple extension that lookup colors codes. ColorZilla is very flexible and can speed color selection significantly. You can select the color using an eyedropper, Platte or color picker. ColorZilla will automatically copy the code to the selected format. The menu brings in also other features like Zoom. Get ColorZilla.

    ColorPicker

  8. MesureIt
  9. Rarely used (as of me), but can come handy sometimes. The extension will help you calculate the width and height of a rectangle you draw on the screen. Install MesureIt now.

    MesureIt

And this is not all, about 1 thousands extensions were made for web developers! You can browse the FireFox library and snatch the best and get the hard work done for you. Find more plugins here.

If you know another FireFox extension worth noting, post in on comments and I’ll try it out.

{ 1 comment }

Fighting Web SPAM

by Omar Abid on June 18, 2009 · 1 comment

in internet

In the few past days, I was busy to keep up with the blog. By mistake, I disabled moderation on blog comments; results: more than 100 comments, totally SPAM.
Bloggers are happy with comments, this mesure the user interaction with the blog post and the success of the writer in attracting attention, but when it happens to be SPAM, then it’s not good and it’s even worse: lose time and bandwidth.

How you get SPAMMED?

  • Mainly, you forget to put the “nofollow” tag on your comments link.
  • You don’t moderate comments and allow them to show automatically.
  • Other bad comments exist which encourage SPAMMERS.
  • You don’t have a SPAM protection plug-in.
  • You don’t check if comment posters are HUMAN.

How to solve those problems?

If you are using Wordpress as a blogging platform, the most popular platform, then a few steps are required to fully protect yourself. Even if they won’t protect you from SPAM for %100, they’ll decrease the number efficiently and increase comments quality

  1. Put a “nofollow” Tag
    To do it and stay compatible with every template you install, just install and activate this simple “nofollow” plug-in. “nofollow” tags, will make searh engines dismiss comment links. If so, SPAMMERS won’t be interested on your links.
  2. Turn moderation “on”
    Moderate your comments, if you have 100 or more in each post, you can disable them and create a forum where your users can discuss the blog post. Good comment moderation will discourage SPAMMERS to attack your blog.
  3. Activate “ASKIMET”
    Askimet is very useful so turn it on, it’ll need 5 minutes if you don’t have a Wordpress API key (don’t worry, all you need is a wordpress.com account)
  4. Check commenters identity
    This is another important step, SPAMMER may not look for links but for traffic, even if it’s small from one comment, it will be big from thousands. Adding a good captcha will help blocking the malicious boots.

When to use captcha: Only when you got attacked, I have been attacked on a blog last year, spammers sent boots that change ip, user name, email and submit hundred, yet thousands of comments! Askimet may protect against SPAM and catch them, but the quantity of comments attack will eat your bandwidth and may cause a huge traffic usage.

Conclusion: If you got spammed, it’s most likely your fault! If you want to help fight SPAM, just begin by securing your system and your code.

{ 1 comment }

The 3 types of blog templates

by Omar Abid on May 12, 2009 · 17 comments

in Blogging

When I started this blog, few weeks ago, I hadn’t a sufficient budget to buy everything. I just setup a hosting with about $60 and asked a freelance to design me the banner as I have no knowledge about it. So the total expenses were less than $100.

Before that, I have talked with peer Blogger (SixRevision) about the blog expenses; he told me that it can reach $2,000. The most expensive thing about it is the blog template.

So I looked for a free template. I thought if I’m not going to hire a freelance and design my own unique template, so it’s not worth to buy one from themeforest.

I watched both templates in ThemeForest and free ones. The paid templates costs between $30 and $50, but they are totally worth it, even if it’s not your unique template.
By chance, I found this one (it was featured) for free. It’s not really premium but good for my small starting.

So what makes a template worth $50 and another one worth $1,000 and the other free?

  • Stock Templates
  • Stock template are generally cheap (less than $50), high quality and very customizable. The seller makes much money of the template, because it doesn’t sell it once, but as many time as it sells. So it’s a good template and cheap, but not unique.

  • Custom Templates
  • You hire a freelance (generally) after checking his portfolio. The freelance will design the blog from scratch (this mean a new CSS structure, new design, customized Jquery effect) and then (may be) setup it on your server. A custom template that concur a stock template in quality can cost $800 or more. The reason bears in uniqueness. It’s your own template, no one on the web had like it.

  • Free Template
  • they are used by %90 of the public. A freelance can make few free templates just to increase his popularity and add in his reputation. So there’s high quality and free template. The problem is, you can’t find them easily due to the large number that adds up every day. Generally, free templates are not professional; they are simple and not very customizable.

    So it depends a lot. If you are a professional Blogger so you need something custom, if you have a small budget then its premium, else, if you are a casual Blogger then you can choose a free one from the crowd!

    What type do you use for your blog?

    { 17 comments }

Intro to Code Input philosophy

by Omar Abid on April 28, 2009 · 2 comments

in diverse

Hey, I’m a 18 years old developer from Tunisia, Sfax. Sfax is a small town with less than 1 million habitant where Information Technology have nearly no value.

I started programming since 11 as I remember, the only thing that excite me about computers, is “copying and pasting an application probably won’t cost money!” .This is quite different than real world. In the computer, it’s all virtual.

When I was 11, I connect few times to the Internet. At that time, it was boring and a little bit addictive; so I prefer to spend most of my time playing Video Games.

When I discovered programming on Qbasic, I though of building applications using this little (open source) compiler. I have no idea about the real IT world; it seems too big to me that I can understand it.
Qbasic was simple and I could understand its few commands. I found also great resources in the Internet. Amateur developers that built games shared source in the internet. It was too complex to understand it in whole, but I hacked a little bit on it.

This is the past. It’s now buried somewhere on my memory. It can never be forgotten or erased. That’s how I began. 7 years ago, I was dreaming of becoming a doctor, this was not my choice. I was just influenced by people surrounding me: my family, friends, society, newspapers… Doctors are important, not because of their job, but because of their money.
Yet most of doctors (in Tunisia) are …

2 year ago, my philosophy changed completely. I can’t imagine myself working rather than a software developer for a company. This was a decision, learning Microsoft Dot Net, getting the Microsoft Certificates, doing some Open source projects to fill my portfolio and getting a job abroad. I dreamt of working as a developer in a company for as long as I can. This was a dream.

1 year ago, I changed my philosophy, again. It has completely changed. A developer in USA can make 70K dollars a year; I can make savings up to 35K dollars, after 10 years, I’ll have sufficient money to return to my native country and live in luxury. But, that’s after 10 years.
That was my dream before, when I was a simple person.
Now I changed, I’m a capitalist. I won’t wait 10 years to do a small wealth.

My philosophy is very simple: the Internet is the solution. When you merge globalization with capitalism, what will you get?
No, not wealth only, but an infinitely growing fortune.
Now what about if you add virtualization to both of them?
The result is very simple: an explosive bomb.

The internet is nothing rather than an explosive bomb; you can drive millions to a place in the same time, if you know how.

Applying this philosophy can lead to a fast growing wealth, that come just from nothing, because in the Internet world it’s all virtual.
Me, I decided to go on that way. This doesn’t mean I won’t work for a company; I would do if I found the opportunity, because this will give me experience. But my secret to wealth is rather simple: Virtual Stock.

Creating an application, with which you can make infinite copies for free, while charging a little fee for each copy. Amazing simple software: easy to create and to market, that has the power to connect people and grow quickly, a small fee to buy, a large number of costumer.

Is it hard to do it? So why developers don’t, why only few succeed?
When the 5 words idea become harder than 25,000 lines!

May be I’m very optimistic… because I read a lot of success stories??

{ 2 comments }