Thursday, February 7, 2008

Using the mail() function in php

I've been using this function quite a lot. I just want to share how to use this function which is very easy.

The mail() function in php is used to send email.

Examples :

$to = "name@example.com";
$subject = "Test Subject"; //be careful to have this as one line or it will not be sent properly
$message = "This is the message";

// sends am email to $to email address with subject $subject and message $message
mail($to, $subject, $message);

//example header
$headers = "From : admin@example.com
Reply-To : admin@example.com";

//this time we added the optional parameter headers
mail($to, $subject, $message, $headers);


That's basically it. Now you know how to send emails in php.

Friday, February 1, 2008

My Programmer's Notebook is back!

At last! It's been a while since blogger mistakenly took my blog as a spam blog. My last post was December 14 last year and after about 5-6 times trying to validate my blog, it's now back. My other blog also had the same problem. But it took around 6 days only when they get it back up again.

I will be posting lots of things soon...

By the way, today is my girlfriend's birthday! :)

Friday, December 14, 2007

Some good tools for web development

I work remotely on most of my projects. Some I need to use ftp to transfer files and some needs to be worked on directly through ssh. The programs I use to do these tasks are putty and coreftp.

Core FTP can be used to connect to the ftp server. It has two versions, Core FTP LE and Core FTP Pro. Core FTP LE is a free software that include ftp features. Core FTP Pro on the other hand is for advanced users that comes with a very low price. Be sure to check them out. Core FTP has been very helpful to me. You can download it here.

PuTTY is a terminal emulator application that can be used for SSH, Telnet, rlogin and raw TCP. I have been using this program for SSH access. It also very easy to use and lightweight. To find out more about putty, you can visit it's homepage here or it's wikipedia entry here. You can download it here.

Thursday, December 13, 2007

Apple Exceeds IBM

I just ran by this article and it pretty much amazed me. Although it's two but old but still... Apple is now worth more than IBM! For the first time in history.

Wow. Good job apple!

Sunday, December 9, 2007

Developing over ftp using vim

Vim, which is short for Vi IMproved, is a text editor that lets you edit a remote file via ftp. It is cross-platform but most popular in Unix-like operating systems.

To use vim, the syntax is : vim ftp:///user@domain//path/file

Example : vim ftp://username@example.com//var/www/index.html

You will be asked for the matching password to your user name after. Just enter the password and you'll have the file opened for editing. Vim has made things easier for me. I hope it will do the same to you.

Saturday, December 8, 2007

Using lftp in copying files between two servers in ssh

LFTP is sophisticated ftp/http client, file transfer program supporting a number of network protocols. It is very useful and I've been always using this. There is this case where I need to login on one server through ssh before I will connect to this server and this has helped me a lot.

To connect to a server type :
lftp -u [username],[password] [servername]

Example : lftp -u username,password example.com

Once you are connected, you can do basic commands like "cd" to change directories and "ls" to list files and subdirectories.

To download a file, go to the directory where you want to download the file then connect to the other server using lftp. Go to the directory where the file you want to copy is located then type :
get [filename]

Example : get myfile.txt

To upload a file, go to the directory where the file is located then connect to the other server using lftp. Go to the directory where you want to upload the file then type :
put [filename]

Example : put myfile.txt

Easy isn't it? And it will help you a lot too. Try it out! :)

Tuesday, December 4, 2007

A few linux commands

It's a slow day today. So I'm going to share some very helpful linux commands. These commands are what I always use every time I work since I log in through the server using ssh. This is just an overview of the basic commands. I might discuss later the advance use of each command.

  1. ls - show files and subdirectories under the current directory.

  2. pwd - shows current directory you are

  3. cd - change directory.
    • to go to the parent directory type "cd .." without the quotes
    • to go into a subdirectory, type "cd yoursubdirectoryname" without the quotes

  4. cp - copies a file or a directory.
    • to copy a file, type "cp originaldirectory/originalfile destination/newfile" without the quotes
    • to copy a directory just add -r like "cp -r originaldirectory destination" without the quotes.

  5. rm - removes a file or directory
    • to remove a file, type "rm filename" without the quotes
    • to remove a directory, type "rm -rf direc" without the quotes

  6. vi - opens a powerful text editor. I use this every time.
This is it for now. I will add more later on about connecting to another server using ssh, etc. I hope these are helpful.