Author Archives: Danny Garcia

Home » Articles posted by Danny Garcia

How to make your iPhone run faster

A nagging problem in the iPhones is that gradually they grow slower and slower. This problem isn’t unique to just the iPhones because most of the phones and tablets grow slow as the applications installed on them keep on getting automatically upgraded and since the original applications are written keeping the hardware of the smart phone in mind as the applications get more features, they get more resource hungry and hence, start putting strain on the hardware. With the iPhone, according to the complaints of its users, this begins to happen quite early. But you can stop an iPhone from getting slower and you can make it run faster using the methods shown in this CNET video embedded below:

Home » Articles posted by Danny Garcia

How to create a child theme for WordPress Twenty Twelve theme

Whenever a new version of WordPress is launched, it also comes with a set of default themes. So previously you might have used the TwentyTen and TwentyEleven themes for WordPress. The latest version is TwentyTwelve, which is basically a framework for building more child themes using it.

If you use the default theme in the twentytwelve folder you get a very minimalistic layout. It’s perhaps the first theme from WordPress that uses not even a single image (on this link you can see an image, but actually when you download the entire theme folder and activate it, it doesn’t show any image).

Although for those who are were looking for a minimalistic layout just to publish lots of text, it might be a perfect theme, but there are many people out there who would like to make certain changes to the way the fonts appear, their sizes and colors, their types, and even other changes here and there.

Altering the core Twenty Twelve files might be a bit difficult for most people, and besides, it is not advisable to change them because then your entire framework may collapse. But there is a solution. Since this thing pretty much acts as a framework, you can build a complete child theme based on it.

Creating a child theme for Twenty Twelve

Building a child theme for Twenty Twelve might be as simple as creating a single style.css file or as complex as creating an entire new file structure. Anyway, once it’s clear how to create a child theme you can go all the way to creating an entirely new theme and the new layout.

In order to create a child theme you will need to create a separate folder inside the themes folder (you can use your preferred FTP program to create the new folder)

/blogroot/wp-content/themes/twentytwelve

As you can see, the child folder is also in the same folder where twentytwelve lives (mind you, not inside it). You can name it anything you want. Inside this folder you have to create the style.css file and it should begin like this:

/*
Theme Name: Twenty Twelve Child
Theme URI: http://example.com/
Description: Child theme for the Twenty Twelve theme
Author: Your name here
Author URI: http://example.com/about/
Template: twentytwelve
Version: 0.1.0
*/

The CSS definitions may seem like commented out, but they actually provide useful information to the CSS file. Here are some quick descriptions of the variables used inside the file (you don’t have to use all)

  • Theme Name: This is required, but as already mentioned above, you can name it anything
  • Theme URI: This is optional and this should ideally be the link to your blog
  • Description: This is optional
  • Author: If multiple people create multiple CSS files at your workplace it would be nice to assign your name to the stylesheet, otherwise it is optional.
  • Author URI: Optional
  • Template: Required. It should be the exact name of the folder that contains the parent theme files, in this case it is normally twentytwelve
  • Version: This is optional. You can create various versions of your child theme.

In case you switched to the child theme before making any changes, you may have to switch to another theme and then switch back to this child theme in order to let the “Template” variable make a difference. If you don’t do this switching, your child theme won’t work.

Since this is a child theme, you will have to import the styles of the parent theme. The following CSS command helps you achieve that

@import url(“../twentytwelve/style.

After this is the usual CSS stuff. Suppose you want to change the font of your blog title, you can easily add this line to your child theme CSS file:

#site-title{
        font-family: Droid, Serif;
        font-size: 50px;<

In the same manner, if you want to change the font of the blog post title you can use the following definition:

h1.entry-title{
        font-family: Droid, Serif;
        font-weight: none;<

Wondering where you get the names of these div IDs and classes? Just open your website, preferably a single blog post (so that you don’t have to load a bigger page), right-click on it (preferably somewhere there is just text) and open the source code. In the source code you will be able to view the divs, the IDs and the classes.

So far we have just discussed the stylesheet file. You can also make structural changes with the help of your child theme. For example, you can add your own functions.php, single.php, page.php and other files just the usual way.

Home » Articles posted by Danny Garcia

How to create a horizontal list menu with CSS

You most probably want to create a horizontal menu for your top navigation bar. You can either use a table with horizontally arranged cells where you can put the links. A more simpler method would be just to use a paragraph tag and then put the hyperlinks separated by spaces, something like

Item 1 Item 2 Item 3 Item 4

The problem with this method is, due to the fact that all the links will be present within paragraph tags, the search engines won’t attach extra significance to the links. On the other hand, if you use a bulleted list to arrange your top navigation items, search engines like Google that take bulleted lists quite seriously, will immediately know that first, since these links are appearing at the top, and second, since they are appearing as a bulleted list, they must be quite important. Of course for SEO benefits you should also use your primary keywords as hypertext instead of simply Item 1, Item 2, etc.

Why not tables? The use of tables have been deprecated and in most of the cases they are not W3C compliant. It doesn’t mean that you cannot use them (almost everybody does), but the most search engine friendly and preferred way of creating horizontal menu bars is creating list menus with CSS.

Conventionally, list menus appear vertically, something like

* Item 1
* Item 2
* Item 3
* Item 4

This arrangement may look good on a webpage or on a blog post, or even on the sidebar, but as top navigation it won’t look good. The items need to be arranged horizontally rather than vertically, as demonstrated above within the paragraph tags.

Let’s create a simple list first of all:

<ul>
        <li>Item 1</li>
        <li>Item 2</li>
        <li>Item 3</li>
        <li>Item 4</li>
</ul>

This will create a simple vertical bulleted list. You will use the following CSS definitions to arrange this list horizontally:

<style>
#listmenu li{
        display:inline;
}
</style>

Now the list will appear something like:

Horizontal bulleted list

This arranges the bulleted list items horizontally. But as you can see there isn’t much space between items and people might not be able to distinguish between one menu item from another. So you will need to add another line to your CSS definitions:

<style>
#listmenu li{
        display:inline;
        padding-right:40px;
}
</sty

This creates a padding of 40 pixels on the right hand side of every menu item and consequently your menu looks like this:

Horizontal bulleted list with CSS formatting

If you have been testing the code along with this tutorial you must be wondering why the CSS changes are not being reflected when you check the webpage. In order to achieve this, you will need to refer to the right CSS ID, in this case “listmenu”; here is how you do it

<ul id=”listmenu”>
        <li>Item 1</li>
        <li>Item 2</li>
        <li>Item 3</li>
        <li>Item 4</li>
</ul>

Of course when you actually implement this list menu you will be using hypertext instead of simply Item 1 etc. You may also like to use different CSS formatting definitions to make the menu look the way you want it.

Home » Articles posted by Danny Garcia

How to enable Android Market on Samsung Galaxy Tab from UAE or Saudi Arabia

If you purchased your Samsung Galaxy Tab from UAE or Saudi Arabia running Android Market it must have been a really frustrating experience because it simply refuses to work. No matter how many times you reset your system or carry out different tweaks, the moment you launch Android Market your Samsung Galaxy Tab vibrates twice and then the application crashes. The problem is not with your tab, the problem is with the settings that come with the gadget if you purchase it from UAE or Saudi Arabia; these countries don’t allow you to use Android Market.

You will find many suggestions on the Internet and most of them don’t work. The solution presented here works on most of the Galaxy Tabs and other android smart phones. First of all you need to take backup of your data and applications because this is going to require a reboot and a factory reset. All you have to do is, tell your phone or the Samsung Galaxy tab that it is not the UAE or the Saudi Arabia settings that it has to follow. For this example, we will reset the phone to the UK settings. So are you done with the backup?

  • First of all, you need to locate your IMEI number. For your device it should be on the backside at the bottom (or anywhere else). If this is a hassle you can also dig out this information from your Samsung Galaxy Tab itself. Go to your home screen and then tap on the “Settings” icon at the bottom. In the Settings screen, locate “About device” and tap it. Then tap “Status”. Here you can see the IMEI number of your device. It is pretty long. Note it down somewhere.
  • Then launch your phone application (the icon that you use to make calls). If you have never used your Samsung Galaxy Tab to make phone calls then there may be some issue but here I am assuming that your device has a SIM card and you can use it to make phone calls.
  • Enter the following information into the box where you often enter the phone number you want to dial: *#272*your device IMEI#
  • That is, star, hash, 272, star, your device IMEI and then hash — enter the information as it is (there are no spaces between different bits of information) otherwise you will generate an error
  • Tap the dial button
  • You are taken to the screen where you can select different Sales Code options
  • Select XSG and tap OK
  • Your Samsung Galaxy tab will reboot and then it will be reset to the factory defaults

But this time when it resets, you will find to your pleasant surprise that Android Market works.

Home » Articles posted by Danny Garcia

How to enable Google accounts multi-sign-in feature

Do you have multiple Gmail or Google accounts? You may have multiple Google accounts for various explainable and inexplicable reasons. If you’re still wondering what’s a Google account it’s basically an account that you create with Google that allows you to use Gmail, Google Docs, Calendar, Google Apps Engine, Google RSS reader and a horde of other services that Google offers for free. Anyway, the whole point is if you have a Gmail account then you also have a Google account and if you have multiple Gmail accounts then you also have multiple Google accounts.

Unless your left hand doesn’t know what your right hand is doing life can be much easier if we can manage all our Google accounts from a single sign-in page. Google now allows you to manage multiple accounts from a single sign-in. What does that mean?

gmail-multiple-sign-in-2

Whenever you are trying to manage more than one Google accounts you have to use different browsers because if you’re using a single browser you first need to logout from your current account and then log into the next one. This can be a very big hassle if you have more than 2-3 accounts. It means you have to have multiple browsers (Firefox, Internet Explorer, Google Chrome, Opera, etc.) open simultaneously. Google has solved this problem by enabling multi-sign-in feature that allows you to manage all your Google accounts once you are logged into one particular account. Sadly, this feature is not active for everybody but according to Google this will be available to all its users very soon.

How to activate the Google multi-sign-in feature

  • Since your current account becomes your default account you should first log into the account you want to use as your default account. Once you are logged into your preferred default Google account you click Settings in the top-right corner.
  • In the Settings section, click the “Accounts and Import” tab.
  • Go to the last option that says “Google Accountant settings”, click this link
  • Under the Personal Settings header you can see the Multiple sign-in option. By default it is off. You can click it and turn it on.

gmail-multiple-sign-in-3

After turning on/enabling the Google multi-sign-in feature it might still be a mystery how to add your other accounts to this account, as nothing visible seems to happen after you have turned on the feature. Look at the top where it normally shows your e-mail address. Instead of the simple link now you will see your e-mail as a hyperlink and there will also be a down arrow that you can click. When you click on that down arrow it shows you a list of all the Google accounts you have currently signed in and it also allows you to sign into another Google account. This is where you add the other accounts. Once you have signed in that account too will start appearing in the drop-down list.

Home » Articles posted by Danny Garcia

How to customize your Twitter profile page background

A customized Twitter profile background page lets you put vital information behind your Twitter stream so that people can know more about you and your business. You can see your Twitter profile page on your Twitter link http://twitter.com/yourtwitterhandle. A typical Twitter page looks like this:

Typical twitter background

Yes, I know, we don’t have a custom Twitter profile page, but we’ll soon have one.

There are two ways, in fact 3 ways you can customize your Twitter profile page background. The easiest among the 3 is using the Settings like at the top. Once you are in the settings section, you click Design, and there you’ll see a selection backgrounds that you can choose for your Twitter profile page background.

Custom twitter background choices

Just click an image and then save changes. You can also change the theme colors.

Another — the more prevalent — way of customizing your Twitter profile page background is by creating your own image. You can your favorite image editing tool to create your custom background. Just make sure it doesn’t get overlapped by the white space that shows your Twitter stream.

While creating a customer Twitter profile page background many people assume that everybody has the same screen size they have. If it matters to you that everybody should be able to view your profile you should take care it’s visible through even smaller screens. Just to make sure your customized Twitter profile page background looks good on most screen resolutions and sizes you can go to this Twitter background checker; enter your Twitter handle it the website tells you how your background fits into major screen sizes.

On the top left corner you should have your image along with your contact information like email (remember that email link won’t be clickable as it’s an image) and phone numbers. This is a good example (click the image for a fuller version):

Good example twitter background

Some people put lots of information on their Twitter profile backgrounds — it depends on you and your business.

The 3rd method involves using 3rd-party tools and utilities to create your custom Twitter profile page background. Twilk, for instance, creates a collage of your followers’ thumbnails and creates a background out of that. ClickableNow, as the name suggests, makes your custom background links clickable. For instance, if you have a link on your Twitter profile page background, people can click that link and go to your website. But a big drawback is that only those can click the links who have installed a browser add-on available on the ClickableNow website.

There are many other tools and utilities available on the Internet that can help you further customize your Twitter profile page background but the above-mentioned methods can surely get you going in the right direction.

Home » Articles posted by Danny Garcia

How to block certain websites from your computer

You can block particular websites from your computer. Are you worried about your kids excessing objectionable websites behind your back or spending too much time on social networking websites? Although your kids may be geekier than you are and some kids simply cannot be stopped from unblocking and accessing certain websites, if you are able to block websites it can act as a deterrence to a great extent.

Benefits of blocking certain websites from your computer

The Internet is a great resource but it can also be a great distraction. When you think your kid is studying all night (they actually used to do that you know?) he or she might be chatting with friends or visiting porn websites or spending a big chunk of their valuable time (the time they can use studying or getting some sleep) on Facebook.

You can block websites even if you cannot resist from using them.

Effectively blocking websites

In order to effectively block objectionable and nagging websites first of all you need to take charge of your computer. Only you or another responsible person should have the admin access to the computer so that if a website is blocked, only someone with an admin access should be able to unblock it. You can restrict access both on Windows and Ubuntu.

Once this aspect is taken care of let’s see how to block particular/objectionable websites on your PC.

Blocking websites in Ubuntu

If you are using Ubuntu you are in much control anyway. Every system level change requires you to enter a password so once you have blocked websites on your Ubuntu PC, only the one knowing the admin password can unblock them.

Open the Terminal Window (Applications -> Accessories -> Terminal). Type

sudo gedit /etc/hosts

and press Enter. You’ll be asked to enter your admin password. The file will be opened in gEdit.

Above the line “# The following lines are desirable for IPv6 capable hosts” you can enter the websites you want to block like this:

127.0.0.1 website1.com
127.0.0.1 website2.com
127.0.0.1 website3.com

and this way you can block all the websites you dislike. Subdomains need to be blocked separately:

127.0.0.1 bad.website1.com
127.0.0.1 website2.com/bad

Save the file and close it. These files are blocked on your Ubuntu PC. I haven’t checked on the older version but on the latest version of Ubuntu 10.04 you don’t need to restart your computer.

Whenever somebody tries to access these websites he or she will encounter the “server not found error”.

Blocking websites in Windows XP

In Windows XP too it’s pretty much the same process. You’ll enter the same sort of information, just the name of the file and its path differs in Windows XP’s case. You need to open the following file:

C:WINDOWSsystem32driversetchosts

It can be C: or whatever drive you have installed Windows XP on. You can use notepad.exe to open this file. It may contain some incomprehensible data. Don’t touch it. Just go to the last line enter the information given above, that is,

127.0.0.1 website1.com
127.0.0.1 website2.com
127.0.0.1 website3.com
127.0.0.1 bad.website1.com
127.0.0.1 website2.com/bad

Save the file. If you can still access the websites, you need to restart your system.

From Windows Vista onwards you need to have admin permissions in order to be able to fiddle with this file.

Home » Articles posted by Danny Garcia

How to create a simple horizontal menu with CSS list

You can easily create a horizontal menu using a CSS list. A CSS list is nothing but the usual HTML list whose display is altered with help of a few CSS definition.

Benefits of creating horizontal menus with CSS lists

SEO is one of the greatest benefits of creating horizontal menus with CSS lists. Lists as such are good for SEO and they further get a boost when they also contain hyperlinks with your primary keywords. Most of horizontal menus are your primary navigation that appear at the top of your website. You can use it to implement your keywords in the beginning of the website.

Another benefit of creating horizontal menu with CSS list is that you can easily manipulate the menu by simply changing the list definition, both in terms of content and layout. You can also use major JavaScript libraries like jquery and Prototype to create highly complicated CSS list drop-down menus.

But in this article I’m simply telling you how to create a simple horizontal CSS menu. Once you know how to arrange a list horizontaly, half of your work is done.

Suppose you have defined the following list for your CSS horizontal menu:

<ul id=”h_menu”>
        <li><a href=”/index.php”>Home</a></li>
        <li><a href=”/our-services/”>Our Services</a></li>
        <li><a href=”/about-us/”>About Us</a></li>
        <li><a href=”/contact-us/”>Contact Us</a></li>
</ul>

Without any CSS, your list may look like this:

css-horizontal-menu-list1

As you can clearly see this is a vertical menu list, and not horizontal. Just one CSS line can turn this into a horizontal menu list from a vertical menu list:

<style>
        #h_menu li{
                display:inline;
        }
</style>

That’s it. “display: inline” does the trick. Your menu now looks like this:

css-horizontal-menu-list2

You can also take some added measures like:

<style>
        #h_menu li{
                        display:inline;
                        list-style-type: none;
                        padding-right:25px;
        }
</style>

So that you don’t see bullets in front of the menu items and there is some space between different items.

Home » Articles posted by Danny Garcia

How to save web form data in a text file

You can save your web form data in a text file instead of saving it in a MySQL table using a simple PHP script. The advantage of doing this is that you might not have the MySQL server installed on your server or you might like to save your web form data in another form.

In fact if you save your web form data in a text file as comma separated values (CSV) you can later on import your data in any file format. For instance, after downloading your text file, you can import the values in an Excel sheet, or into an Access table, or later on, even in a MySQL table. You can use it with any software the uses comma separated values.

Saving web form data in a text file with PHP

Why PHP? First of all, I’m more comfortable with PHP. Second, in order to achieve this you need some server side scripting and there is a 99.99% chance that your web host allows PHP scripts. So that’s now out of our way.

Suppose you have the following web form on your website or blog:

<form name=”web_form” id=”web_form” method=”post” action=”process-form-data.php”>
        <p><label>Enter name: </label><input type=”text” name=”name” id=”name” /></p>
        <p><label>Enter email: </label><input type=”text” name=”email” id=”email” /></p>
        <p><input type=”submit” name=”s1″ id=”s1″ value=”Submit” /></p>
</form>

Since we only need an example so we’ll have just two fields for the form, namely name and email. Next, create a text file containing this line:

Name,Email

and name it as, say, formdata.txt. As you can see, it has a comma between the two headers. Also press the Enter key once after writing Email just so that the end of file pointer is in the next line. Upload this file to the folder where you have your web form file and the PHP script file that will save your form data in this text file. Make sure your text file is writable on the server (the file permission should be set to 666) and you can do it by right-clicking it through your FTP client.

Now to the file where the real action happens, that is, “process-form-data.php”. This file contains the following lines of code:

<?php
$name = $_POST[‘name’];
$email = $_POST[’email’];
$fp = fopen(”formdata.txt”, “a”);
$savestring = $name . “,” . $email . “n”;
fwrite($fp, $savestring);
fclose($fp);
echo “<h1>You data has been saved in a text file!</h1>”;
?>

The first two lines saves the web form post data in local PHP variables. The 3rd line opens the text with the appropriate permission. In PHP we can open files with difference permissions, but here, “a” means open the file in write-mode and append the new information (without overwriting the existing information. You can refer to PHP official documentation for all file opening permissions. Just remember that a wrong permission can delete your file or erase all your data.

The 4th line creates a string that combines the two values — name and email — puts a comma between them and then inserts the new line character so that the end of file pointer moves to the next line.

The fwrite function writes the newly-created line and the remaining code is very easy to understand.

If you are not saving very critical data, saving your web form data in a text file is better than saving it in a database table as then it is easier to access it without extra programming knowledge.

Home » Articles posted by Danny Garcia

How to start an application remotely

You can start an application remotely with the help of DropBox and AutoHotkey. DropBox is a cloud-based service that lets you keep your files on a remote server so that you can access them from any computer running any operating system. Well, by any…at HowToPlaza we’ve just tried it on Ubuntu and Windows XP. AutoHotkey on the other hand is an open source utility for Windows and you can use it to automate many Windows tasks and create keyboard shortcut keys.

In order to use the combination of DropBox and AutoHotkey to start an application remotely both these utilities must be installed on your PC (where you want to run the application) and they should be actively running. When you install and run AutoHotkey the scripts used can be run as executables.

The DropBox installation program will create a folder where you’ll normally store all the files that you want to syncronize with your cloud-based account.

For this example, let’s suppose you want to run FireFox remotely. You can create an AutoHotkey containing the following lines:

Loop
{
Sleep, 180000
Reload
}

store it in your DropBox folder and then double-click on it. It’ll start running. 180000 makes sure the file is reloaded every 3 minutes (3×60 seconds x 1000 milliseconds).

Leave your computer on and let your script run.

Now suppose you are in another city and you would like to launch FireFox from there. This is just for explanation and no purpose is actually solved by merely launching the browser like this. Anyway, using the other computer or laptop that you have with you at the remote location you go to the folder having the synchronized versions of your DropBox files. From there you open the above mentioned AutoHotkey file and add the following line above the Loop:

Run, “firefox.exe”

So now the file becomes:

Run, “firefox.exe”
Loop
{
Sleep, 180000
Reload
}

Save the file. After 3 minutes FireFox will be remotely launched. Remember to remove the line running FireFox after 3 minutes and then save the script, otherwise it’ll keep launching FireFox every 3 minutes.

So this is how you can start an application remotely, using DropBox and AutoHotkey.

Home » Articles posted by Danny Garcia

How to stop people from hotlinking to your images

Want to stop people from hotlinking to your images and save tons of bandwidth? When you display images on your website or blog it costs you bandwidth. So if you display an image that is 23 Kb, whenever somebody loads your page and consequently, loads your image, you’ve spent 23 Kb of the allocated bandwidth from your hosting company.

What does hotlinking to your images actually mean? Suppose the exact path to your image files is http://yourdomain.com/images and the exact path to a particular image, let’s say thisimage.jpg is http://yourdomain.com/images/thisimage.jpg.

Anybody can hotlink to this image by directly using the path from his or her website without uploading the file to his or her server like this:

<img src=”http://yourdomain.com/images/thisimage.jpg” alt=”I am an bandwidth thief” />

So whenever the image is being loaded on that offender’s website, your 23 Kb of bandwidth is being spent because it’s actually your server that is providing the image. Imagine if that website is getting thousands of hits per day.

You can easily stop people from hotlinking to your images by making changes in your .htaccess file. This file normally resides in your root folder, so you should download it and take a backup before altering it. Even a small mistake can make your entire website unavailable. Besides, WordPress creates its own .htaccess file if you are running your blog with it.

So once you have your .htaccess file with you, you need to do the following:

RewriteEngine on

We need to use the Apache module mod_rewrite. There is a great probability that you can use it on your server. The above line turns the Rewrite engine on.

RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?yourdomain.com [NC]

You need to tell the engine that it’s OK if your own website links to the images — after all you’ll be using these images on your own website or blog.

RewriteCond %{HTTP_REFERER} !google. [NC]
RewriteCond %{HTTP_REFERER} !search?q=cache [NC]
RewriteCond %{HTTP_REFERER} !msn. [NC]
RewriteCond %{HTTP_REFERER} !yahoo. [NC]
RewriteCond %{HTTP_REFERER} !bing. [NC]

Since most search engines allow their users to search for images and since you can get lots of traffic through image searches, you should let all the major search engines to hotlink to your images. You can decide not to, though.

RewriteCond %{REQUEST_URI} !^donthotlink.gif$

If you want to show a particular image instead of the actual image — thisimage.jpg in your case — donthotlink.gif will be displayed instead.

RewriteRule .(jpe?g|png|gif)$ donthotlink.gif [NC,R,L]

This is what finally stops hotlinking. This tells the server to show “donthotlink.gif” if somebody tries to hotlink one of your jpe, jpg, png or gif files. You can add more format. Since “donthotlink.gif” may again cost you bandwidth you can store it using one of the free image hosting services and then use the direct link here.

So this is how you can save bandwidth and stop people from hotlinking to your images.

Home » Articles posted by Danny Garcia

How to do page redirection in PHP

You must be wondering why do page redirection in PHP if you can easily do it with HTML? In HTML, you can simply put the following line in the <header></header> are and you can redirect the page to your desired link:

<META HTTP-EQUIV=”Refresh” CONTENT=”10; URL=the-new-link”>

CONTENT=10 means that redirect the page after 10 seconds. If you want to redirect immediately you can use 0 (zero) instead of another number.

So if page redirection is such a simple task, why do it in PHP? Since PHP is used to create dynamic pages, you may have to redirect your visitors to different pages according to the if-then logic, something like

if result is 10
then go to page1.html
else
go to page2.html

A good example is [please read how to store online form data into MySQL database using PHP] showing a thank you page after processing the form data entered by your visitor (either mailing you the form data or storing it somewhere)

For redirecting pages in PHP we use the header() function in such a manner:

<?php
header(”Location: the-new-link”);
?>

For a thank you page you can have:

<?php
header(”Location: thank-you.php”);
?>

You just need to make sure before using this command no output has taken place. There should have been no echo() or print() function used and you shouldn’t have used HTML tags to display some text on the web page [read how to mix html and PHP]

Home » Articles posted by Danny Garcia

How to upgrade to WordPress 3.0 called Thelonious

Upgrade to WordPress 3.0

WordPress released the final version of 3.0 (code named Thelonious) yesterday and we have started upgrading all our blogs. Why should you always upgrade to the latest version. For security reasons, if nothing else.

Every new release of WordPress plugs the security holes that may have existed in the previous version [read how to make your WordPress blog more secure]. So even if you’re not looking for new features, installing the latest version always increases the safety of your blog.

BEFORE UPGRADING make sure you have backed up your existing blog posts, in case something goes wrong (nothing should go wrong, but then, you never know).

Upgrading to WordPress 3.0 (Thelonious)

You can upgrade to WordPress 3.0 in two ways: through your Dashboard and by uploading the files manually. Whenever you log into your Dashboard at the top you’ll be able to read “WordPress 3.0 is available! Please update now.” By clicking the link you can start the upgrade process. If your current version is very old then you may not be able to upgrade to the latest version automatically.

Your web host may also help you upgrade to the latest version. Some web hosts automatically take care of your WordPress updates.

If you are comfortable using an FTP program (FileZilla, for instance) you can download the version 3.0 to your local hard drive from this link. You’ll need to uncompress it.

Then launch your FTP program and go the folder where you’ve installed your WordPress blog. Assuming you are using FileZilla, the left hand side window contains your local files and the right hand side window contains the file on the remote server. Go to the folder (on the left hand side) where you have uncompressed the WordPress files.

Select all but LEAVE wp-content and wp-config.php in case it exists. This is because wp-content contains your themes and plugins — overwriting this will completely destroy your current blog layout and other settings. wp-config.php contains settings that connects your blog to your MySQL database.

On the right hand side, go to the folder where you have installed your blog. Upload the new files.

Then in your browser window, type http://yourdomain.com/yourblog/wp-admin/upgrade.php and press Enter. If you have installed your blog in the root folder you can simply use http://yourdomain.com/wp-admin/upgrade.php.

It’ll ask you to update your database and let it do. That’s it. Once you have followed these steps you have upgraded to WordPress 3.0.

Home » Articles posted by Danny Garcia

How to run DOS in Ubuntu

Although you’ll rarely need to run DOS under Ubuntu it does no harm to know how it is done. There are some great things you can do in DOS, for instance, run the good old DOS games, if nothing else.

The fans of DOS loved the operating system for its sturdiness and the ability to use the command prompt but if you like doing simple things in a difficult manner in Ubuntu you can run all commands on the Terminal windows.

Anyway, in order to run DOS under Ubuntu you require DOSBOX. You can install it either through the Synaptic Package Manager or by simply running the following command in the Terminal window:

sudo apt-get install dosbox

This installs DOSBOX on your computer. In order to run your DOS programs under Ubuntu now you need to create a folder, preferably using the path:

/home/username/dosprogs

“username” can be your name, or whatever login name you use with your Ubuntu system. Once that’s done, move all your DOS programs to this folder.

You can run DOSBOX using the following command in the Terminal window:

sudo dosbox

Initially you’re in Z: drive and if you try to go to C: drive you cannot go. So every time you launch DOSBOX you’ll need to mount your folder to a drive using this command (in the DOSBOX prompt):

mount h /home/username/dosprogs

This way whatever resides in “dosprogs” whether files or folder, can be accessed once you’ve gone to H: drive.

But it can be tedious to mount your folder to a drive each time you start DOSBOX. You can do it automatically each time you start the DOS utility under Ubuntu.

How to auto-mount a drive in DOSBOX

Start DOSBOX and at the Z: prompt execute

config -writeconf /home/username/dosbox.conf

This creates a DOSBOX configuration file in your home folder. Please note you need to create this file in your username folder and not in dosprogs.

You can quit DOSBOX after this.

Then open this newly-created file in gedit and go to the line that has [autoexec].

Under that line, just add

mount h /home/username/dosprogs

and save the file. The next time you launch DOSBOX this folder will already be mounted on a drive.

Home » Articles posted by Danny Garcia

How to store your form data to MySQL

You can easily store your form data to MySQL because it comes free with almost every web hosting package. When you have a web form on your website or blog you have various options for handling data submitted by your visitors:

  • Mail the form data to a particular email address
  • Store the data in a text file (we’ll cover this in another post)
  • Store the data to MySQL in a database table

Once you’ve stored data into a MySQL table you’ll be able to analyze it in many forms, and precisely this is the reason why data is stored in databases. You can run queries and create reports once you have substantial data.

Creating a MySQL database table

Every web host comes with a MySQL link that enables you to manipulate your database, most probably, using phpmyadmin. In order to create a MySQL table you first need to create a database. Using phpmyadmin you can easily create a new database. You can also use an existing database by simply selecting it from the list of existing databases.

It’s better to write down the structure of your MySQL table before creating it. Suppose you want to collect the following information:

  • First name
  • Last name
  • Gender
  • Age
  • City
  • Date of form submission

The last one you can straightaway derive from the system. So with this information, we create a new table by first clicking the SQL table and then entering the following standard SQL query/command:

CREATE TABLE form_data(
        id integer NOT NULL AUTO_INCREMENT,
        first_name VARCHAR(255),
        last_name VARCHAR(255),
        gender VARCHAR(10),
        age INTEGER,
        city VARCHAR(255),
        submit_date DATE,
        PRIMARY KEY(id));

After entering this click “Go” and your MySQL table “form_data” will be created.

Creating a web form

You’ll need to create an interface that your visitors will use to submit this data. You can have this basic form:

<form name=”web_form” id=”web_form” method=”post” action=”process-form-data.php”>
        <p><label>Enter first name: </label><input type=”text” name=”fname” id=”fname” /></p>
        <p><label>Enter last name: </label><input type=”text” name=”lname” id=”lname” /></p>
        <p><label>Select gender: </label><select name=”gender” id=”gender”>
                <option value=”-” selected=”selected”>-</option>
                <option value=”Male”>Male</option>
                <option value=”Female”>Female</option>
                <option value=”NA”>NA</option>
        </select></p>
        <p><label>Enter age: </label><input type=”text” name=”age” id=”age” /></p>
        <p><label>Enter city: </label><input type=”text” name=”city” id=”city” /></p>
        <p><input type=”submit” name=”s1″ id=”s1″ value=”Submit” /></p>
</form>

Whenever you have a web form you have another file associated with it that handles the data submitted by your visitors. Whatever happens to you form data, it happens in this file. In our example that file is “process-form-data.php”; we tell to the form what “action” to take once the data is submitted.

Creating the server-side script that stores your form data to MySQL

I’ve used a PHP file here but it’s up to you what server side language you want to use. You can use Perl, or Python, or CGI, or a horde of server-side programming scripts and languages available for different platforms. Our “process-form-data.php” contains the following PHP code that first captures all the form values into local PHP variables and then inserts them into the MySQL table we created above (comments are preceded by //).

<?php
// Connecting to the MySQL server
$host=”mysql.yourdomain.com”;
$user_name=”username”;
$pwd=”kj67GbF54″;
$database_name=”visitors”; //assuming you created this
$db=mysql_connect($host, $user_name, $pwd);
if (mysql_error() > “”) print mysql_error() . “<br>”;
mysql_select_db($database_name, $db);
if (mysql_error() > “”) print mysql_error() . “<br>”;
// Storing form values into PHP variables
$fname = $_POST[“fname”]; // Since method=”post” in the form
$lname = $_POST[“lname”];
$gender = $_POST[“gender”];
$age = $_POST[“age”];
$city = $_POST[“city”];
$submitdate = date(”Ymd”);
// Inserting these values into the MySQL table
// we created above
$query = “insert into form_data (first_name, last_name, gender, age, city, submit_date) values ('” . $fname . “‘, ‘” . $lname . “‘, ‘” . $gender . “‘, ” . $age . “, ‘” . $city . “‘, ‘” . $submitdate . “‘)”;
$result = mysql_query($query);
// mysql_query() is a PHP function for executing
// MySQL queries
echo “<h1>Thank you for submitting your details!</h1>”;
?>

When you are storing values into MySQL tables you need to enclose the alphanumeric, date and text values within quotes and that’s why you see those three single quotes. They are actually a single quote followed by a double quote: the single quote becomes part of the final SQL string that may look like:

insert into form_data (first_name, last_name, gender, age, city, submit_date) values (‘Danny’, ‘Garcia’, ‘Male’, 23, ‘LA’, ‘20100615’)

As you’ll note the number 23 is not enclosed within quotes, and if it, it becomes a character value.

So this is how you store your form data in MySQL.

Home » Articles posted by Danny Garcia

How to create a beveled text effect with CSS

You can easily create the beveled text effect using CSS. Although you may wonder why learn a new technique to create the beveled text effect when you can easily do it in an image editing software, the advantage of using CSS is that once you have defined a class, you can invoke the effect wherever you want to.

There is no dedicated style attribute in CSS that creates the bevel effect but you can use the CSS text shadow effect to attain the same. You just need to choose the right colors.

For better effect, chose a darker shade of background for the beveled effect because then you can see it clearly. For instance this looks fine:

beveled-text-effect-css-1

But if you choose a very light background, the bevel effect will not look as good:

beveled-text-effect-css-2

So it’s all about what color you choose. Getting back to creating the beveled text effect with CSS, the following definition does the trick (the better one among the above examples):

<style>
        .container{
                background-color: #8295CC;
                width:300px;
                height:100px;
                text-align:center;
                padding-top:30px;
        }
        .bev{
                color:#394F91;
                font-size:2em;
                font-family:sans-serif;
                text-shadow: 0px 1px 0px #C8D0E7;
                font-weight:bold;
        }
</style>

And this is how we use it:

<div class=”container”>
        <h1 class=”bev”>HowToPlaza</h1>
</div>

It’s basically using the color of the shadow, and then strategically placing it in such a manner that it creates the bevel effect. In this effect the text should either appear raised or engraved. In our case we’re raising the text. So over a dark background we’ve used a lighter color shadow under a darker text. This gives you the desired beveled text effect. You can keep changing the CSS color values according to your need.

Home » Articles posted by Danny Garcia

How to draw circles in GIMP

If you want to draw a shape like a circle in GIMP there is no direct button. But it doesn’t mean you cannot create different shapes in GIMP. It just takes a little bit of knowledge, and of course, effort.

GIMP basically is an image editing tool for Ubuntu and other versions of GUI Linux operating system. In fact it has grown so much that it is no longer considered a basic image editor: in Ubuntu 10.04 it is no longer installed by default while you are installing the operating system, you install it only if you need it.

Although here on HowToPlaza we’ve already covered how to draw basic shapes in GIMP, since lots of search engine queries are based on individual shapes, this tutorial is specifically for creating circles in GIMP.

Start GIMP and open a new file. From the tool box select the Ellipse Select Tool:

Ellipse select tool for drawing a circle

This tool helps you select a circular region in the drawing area. In order to draw a perfect circle (with a fixed radius) it is often advised that you keep the SHIFT key pressed while drawing the circle but we’ve observed it doesn’t work; it doesn’t mean you need to depend on your eye-hand coordination in order to draw a perfect circle in GIMP. After you have drawn your circle, whatever shape, refer back to the Tool box. At the bottom you have options that let you set the height and width of the circle by manually entering the numbers:

Creating a perfect circle manually

This way you can create the shape of a perfect circle. But it isn’t over yet. You need an outline. For creating an outline you need to decide the color, the width, and type of outline you want. As type, you can use the Brush or the Pencil or the Airbrush tool:

Selecting the drawing tool

You can adjust the width and other features of these drawing tools

Setting different features of drawing tools

Once you are through with all the settings, click Edit in the main menu and then click Stroke Selection. You get the following window:

The stroke selection window

Here too you can pay around with different settings. In fact all the features that we’ve discussed above can be altered through this window too. Finally, click Stroke.

You have drawn a circle in GIMP

Drawn a perfect circle in GIMP

Home » Articles posted by Danny Garcia

How to have different webpage titles for your WordPress blog posts

An SEO-related issue with WordPress is it uses the blog post title as the webpage title too. Wondering what’s the difference? A blog post title is the big text you see above every post content. The page title is the text you see in the title bar of your browser window.

Webpage title example

Whereas people prefer to use enticing and catchy blog post titles they may not carry the SEO qualities that can fetch better search engine rankings [read how to search engine optimize your blog post titles http://www.howtoplaza.com/how-to-search-engine-optimize-seo-your-blog-post-titles/]. You need to find a way where you can use different webpage titles for your WordPress blog posts.

Fortunately, there are many theme frameworks that let you enter webpage titles that are different from the blog post titles, and one of them is the WordPress Thesis theme.

thesis-theme-different-titles

Thesis allows you to enter custom title tags for your webpages that are different from your blog post titles. As you can see here you can also add custom Description and Keywords too.

If you don’t want to spend money on a commercial WordPress theme framework you can use the All-In-One-SEO-pack plugin. Aside from helping you search engine optimize your blog it also lets you enter custom webpage titles that can be totally different from your blog post titles. Once you install the plugin and tweak it the extra fields appear where you are creating the news blog post or editing an existing one.

all-in-one-seo-pack-screenshot

Using these fields you can have different, customized webpage titles for your WordPress blog posts.

Home » Articles posted by Danny Garcia

How to modify the structure of a MySQL table

Need to modify or alter the structure of a MySQL table that you created a while ago? Before you carry out the changes you must know that if you haphazardly change the structure of your MySQL table you might lose your data. So make sure you know what you are doing.

You may lose your data while making the following changes in your MySQL table:

  • By altering the type — from integer to text or some other type
  • By deleting the column

Now coming back to altering the structure.

Suppose a while ago you created a MySQL table called “tourists” with the following structure.

name varchar(255)
destination varchar(255)
id integer not null auto_increment

Then you realized the name should in fact be in two separate fields, viz. first_name and last_name. Now whatever data is there in the current name field you can have it in the new first_name field and in the new last_name field you can manually enter the new values. But let us see how you can change the name to first_name and last_name:

ALTER TABLE ‘tourists’ CHANGE ‘name’ ‘first_name’ VARCHAR(255);
ALTER TABLE ‘tourists’ ADD COLUMN ‘last_name’ VARCHAR(255);

We have in fact executed here two commands simultaneously to change the structure of our MySQL table.

This is highly improbable but you can also change the type of a field. Let’s say you want name to be an integer. You change it like this:

ALTER TABLE ‘tourists’ CHANGE ‘name’ ‘name’ INTEGER NOT NULL

You can also use MODIFY to change a column definition:

ALTER TABLE ‘tourists’ MODIFY ‘name’ INTEGER NOT NULL