Saturday, November 29, 2008

I am still alive

It has been a while I didn't update this blog, since I was too busy managing a sports event at my place.

Today I'm not going to post anything about PHP functions. Instead, I would like to give a big thank my loyal readers on being such a concern asking me if I'm still alive.

I'm telling you guys, I'm still alive healthily and happily right now. I won 4 medals in the annual event — gold medals for badminton and rope pulling, silver medals for volleyball and soccer. What a worth busy moments!

After all, thank you for being so patient waiting for my updates. I'll definitely update this blog soon.

Saturday, October 18, 2008

Fortunate vs Unfortunate

My hard disk crashed, totally damaged. This is real sick.

Fortunately it is still under warranty. Unfortunately it takes too much time to be replaced.

Fortunately not more than a month to wait. Unfortunately I lost all my data.

Fortunately I got backup. Unfortunately the last one was about three months ago.

Fortunately I can get back all my PHP applications. Unfortunately not the latest one.

Fortunately I can get back my MySQL data, too. Unfortunately not the latest one, too.

Fortunately I can set back my work after the new one arrived. Unfortunately I didn't backup all my software as they eat lots of disk space.

OMG, I don't know what to do, where to start, how to complete. It's real hard.

What do you think when fortunate vs unfortunate. Which one wins?

Saturday, September 27, 2008

Prevent accidental window closing: alert onbeforeUnLoad

Today, I'm going to show you how to stop your visitor to close window of your site, using JavaScript.

It's useful when they have unfinished processes, or unsaved data, in which they whether accidentally or deliberately clicked on the close button of your page.

It's also useful for your marketing strategy, like one-time offer, final discounts, and so on.

Simple. First, use this following function. Then I'll show you with 3 situations for example.

var askFirst = false;
function preventerOn() {
askFirst = true;

function preventerOff() {
askFirst = false;
window.onbeforeunload = sureUnload;
function sureUnload() {
if (askFirst)
return "Are you sure you want to exit this page?";

Situation 1, if you want to prevent window closing from the beginning, you may want to use the body tag, like this:

<body onload="return preventerOn();">

Situation 2, if you want to prevent window closing when your visitor enter something in a form, use it like this:

<input type="text" name="input1" onchange="return preventerOn();">

Situation 3, if you want to prevent window closing before reached an amount of time (i.e: 20 seconds), you may add this one to the script above:

function setTimer() {
setTimeout("clear();",20000); // 1000 is for 1 second, so 20000 is for 20 seconds
function clear() {

You may need to change in the body tag, from this:

<body onload="return preventerOn();">

to this:

<body onload="return setTimer();">

That's all.

If you have any questions regarding this, please feel free and don't hesitate to ask me through the comment form.

Thank you.

Monday, September 22, 2008

More elaboration on 'signed-by' and 'mailed-by'

A friend of mine, Tim recently asked me about the mail function in PHP programming which I wrote on how to edit or remove the default 'signed-by' or 'mailed-by' label during the sending activity.

His question is, where to put the code? As far as I'm concerned, I was not talking about the code, or even code positioning.

I'm talking about a particular technique that we would use in order to edit or to remove the distracting label when we use mail() function in our code (programming).

The real situation yet to be explained
The default value for the labels is usually the domain name of the server hosting company we run from.

In example, let say you use a web hosting from the well-known BlueHost company. Then you planned to send mass email to your friends about your new site, without revealing your friends' details among them.

So all you need to do is having your list in a database, and then use loop function to send mail to them, one by one, using the php mail() function. Perhaps, you'll use a fake email, or your self-hosted email, or even your true email from Google mail or Yahoo! mail.

Unfortunately, when using this method, recipients will see the header (if they checked on it) of the email, stated that the mail you sent was mailed by (in example)

This is what we don't like to see. It'll tell the recipients what hosting service we are using.

So, in order to remove or edit the default value, we need to do those things that I explained earlier. To see the post, click here.

I hope my friend Tim will get what I was actually saying. What say you?

Friday, September 19, 2008

Edit or remove 'signed-by' or 'mailed-by'

Recently I was trying to remove the labels 'signed-by' or 'mailed-by' which displayed the server name of my web hosting company when I do mailing activities from PHP script.

I was actually wanted to have my domain or perhaps my 'fake' domain address to be there. I don't want to display the web hosting company.

The labels are like distracting me as a mailer, because I don't really need that to be displayed. They're like disturbing my privacy.

After having some research, I finally found the answer. There's actually five arguments in the mail() function, instead of just four like this:

The fifth argument is the answer to my question. I believe some of you might get in the same situation.

So lets get straight to the point. Choose one of these below:
  1. You want your domain to be displayed; or
  2. You want nothing to be displayed.
You can't have them to display other than that. I.e: You want it to display 'signed-by:' or 'mailed-by:'. No you can't have it. Just choose one of the stated above.

If you want the first choice, do this:
  1. Create an email address from your domain, or take one you've had, like
  2. Set your code like this:
  3. There's no number 3, you're done!
If you want the second choice, you only have to do the second one in the first choice. You may change the '' to any email you'd like, i.e:

Easy, huh?

Wednesday, September 17, 2008

I'll be continuing from now on...

I've paused my blogging activity for such a long period. I think I have to go back to work, from now on.

Recently, I signed up for EntreCard. I wanted to see how exactly this program works. If I find this social networking tool helping me much i building my personal ranking, I would stay. Otherwise, I'm moving away. 

So let's give it some time. Maybe I should try this for about a month or two. What say you?