Latest articles
10 Windows keyboard shortcuts you possibly didn't know about
2009-09-22 12:25:52
Keyboard shortcuts are a vital time-saver. Here are ten that you possibly didn' already know about.
Active window Screenshot
ALT + Prt Scn
Holding the Alt and Print Screen buttons simultaneously will enable you to take a screenshot of just the active window, rather than the whole screen. This avoids the need to crop some images.
Lock Computer
Windows + L
Holding the Windows key and the letter L will automatically lock your computer. This protects you if you are leaving your PC unattended, because you will need to enter your password to get back in.
Open Windows Explorer
Windows + E
Holding the Windows key and the letter E will open Windows Explorer. This is basically like My Computer, but the 'Folders' Explorer Bar is turned on by default.
Searh for files and folders
Windows + F
Holding the Windows key and the letter F will open the Windows search feature.
Minimise all windows
Windows + M
Holding the Windows key and the letter M will minimise all open windows. This is great if you need instant access to your desktop. The Show Desktop command (Windows key and the letter D) will also achieve this.
Undo minimise all windows
Windows + SHIFT + M
Holding the Windows key, the Shift key and the letter M will restore any windows that were minimised by the "Minimise all windows" shortcut. The Show Desktop command (Windows key and the letter D) works as a toggle, so can be used to undo the Windows + D shortcut, but it cannot be used to undo Windows + M.
Show System Properties
Windows + BREAK
Holding the Windows key and Break key simultaneously will open the System Properties. This avoids going through the Control Panel or right-clicking My Computer to choose 'Properties'.
Rename file
F2, when a file is selected
Holding the F2 key when you have a file selected within Windows Explorer, will enable you to rename the file.
Prevent autorun
SHIFT, when inserting a CD
Holding the Shift key whilst you insert a CD and the disc is loading will prevent the disc's autorun from being activated.
ALT + F4
Shut down Windows
Holding the Alt key and the F4 key simultaneously will enable you to shut down Windows. You may already know that when you have a program open, Alt + F4 will close the application for you. However, you are less likely to know that the same principle can be applied to shut down Windows. You do this by going to your desktop and holding Alt + F4.
Active window Screenshot
ALT + Prt Scn
Holding the Alt and Print Screen buttons simultaneously will enable you to take a screenshot of just the active window, rather than the whole screen. This avoids the need to crop some images.
Lock Computer
Windows + L
Holding the Windows key and the letter L will automatically lock your computer. This protects you if you are leaving your PC unattended, because you will need to enter your password to get back in.
Open Windows Explorer
Windows + E
Holding the Windows key and the letter E will open Windows Explorer. This is basically like My Computer, but the 'Folders' Explorer Bar is turned on by default.
Searh for files and folders
Windows + F
Holding the Windows key and the letter F will open the Windows search feature.
Minimise all windows
Windows + M
Holding the Windows key and the letter M will minimise all open windows. This is great if you need instant access to your desktop. The Show Desktop command (Windows key and the letter D) will also achieve this.
Undo minimise all windows
Windows + SHIFT + M
Holding the Windows key, the Shift key and the letter M will restore any windows that were minimised by the "Minimise all windows" shortcut. The Show Desktop command (Windows key and the letter D) works as a toggle, so can be used to undo the Windows + D shortcut, but it cannot be used to undo Windows + M.
Show System Properties
Windows + BREAK
Holding the Windows key and Break key simultaneously will open the System Properties. This avoids going through the Control Panel or right-clicking My Computer to choose 'Properties'.
Rename file
F2, when a file is selected
Holding the F2 key when you have a file selected within Windows Explorer, will enable you to rename the file.
Prevent autorun
SHIFT, when inserting a CD
Holding the Shift key whilst you insert a CD and the disc is loading will prevent the disc's autorun from being activated.
ALT + F4
Shut down Windows
Holding the Alt key and the F4 key simultaneously will enable you to shut down Windows. You may already know that when you have a program open, Alt + F4 will close the application for you. However, you are less likely to know that the same principle can be applied to shut down Windows. You do this by going to your desktop and holding Alt + F4.
Randomly Selecting Images with PHP
2009-09-07 19:17:18
Have you ever seen an image on a web page and wondered how it is randomly replaced with a different one when you click "reload" in your web browser?
This is a neat little trick that can be done in PHP and it is so easy. This article will explain how to do it.
First of all, you will need to write the PHP part of the code, which will randomly select the image. After that, you will place the PHP variable into the HTML.
Once that is done, you will need to add the variable $random_image into the page, like so:
Once you have used this code, try a few page refreshes. You should see that it displays a random image from the selections.
This is a neat little trick that can be done in PHP and it is so easy. This article will explain how to do it.
First of all, you will need to write the PHP part of the code, which will randomly select the image. After that, you will place the PHP variable into the HTML.
<?
$image_array = array("images/1.jpg", "images/2.jpg", "images/3.jpg"); /* the paths of the images - to add extra paths, just follow the existing pattern: encased in quotes and separated by a comma */
$selection = $image_array[array_rand($image_array)]; /*this is the random choice of array value*/
$random_image = "<img src='".$selection."' />";
?>
$image_array = array("images/1.jpg", "images/2.jpg", "images/3.jpg"); /* the paths of the images - to add extra paths, just follow the existing pattern: encased in quotes and separated by a comma */
$selection = $image_array[array_rand($image_array)]; /*this is the random choice of array value*/
$random_image = "<img src='".$selection."' />";
?>
Once that is done, you will need to add the variable $random_image into the page, like so:
<html>
<body>
<? echo $random_image; ?>
</body>
</html>
<body>
<? echo $random_image; ?>
</body>
</html>
Once you have used this code, try a few page refreshes. You should see that it displays a random image from the selections.
How to create a simple contact form in PHP
2009-08-30 19:02:52
An online contact form is quite a handy feature for your website. It can be used as an additional way for your visitors to contact you, and if you don't feel like displaying your email address for those nasty spammers to get hold of it, you don't have to. This article explains how you would create a simple contact form for your website.
To create an online contact form, you will need two parts.
1) The HTML for the form that is used by your visitors.
2) The PHP server-side code that interprets the form and sends it as an email.
Your online contact form will look something like this:
So let's take a closer look at the key parts of this:
This opens up the form so that the web page knows to treat everything inside as part of the form.
method='post' is used so that the data is sent behind the scenes to the server using the HTTP POST method. The alternative would be to use the HTTP GET method which would make the data visible within the URL. This can be messy, as the user's URL will contain the whole text of the message along with all other submitted information. Also there is a limit to how much data can be sent through GET, whereas POST is not limited.
This is a handy little piece of HTML. It will allow the user to click on the words "Your name: " and it will activate the associated input box.
This is where the name is entered into the form.
This is where the message is entered. Unlike the inputs, this will appear as a box with multiple rows, rather than a single line.
This is the Submit button. It is a special type of input that will submit the HTML form, according to its method. In this case we chose the POST method. The value will display the words "Send message" onto the button.
Great! That's the HTML sorted. Now onto the PHP...
This starts the PHP code
This is only called if the user clicked the Submit button with value "Send message"
Defines the email address that messages will be sent to and the subject that will be given to these messages
Choose the character set. This is the default character set which you would normally use in English language. The \n is the newline character.
This sets the message as from the person and email address specified. Once again \n is used as a newline character.
.= is used instead of equals on its own, because the header is being added to the existing $email_headers variable.
This runs the mail function and also an if statement that checks if the mail() function was successful or not
If the mail function was successful, the above variable is assigned
If the mail function failed, the above variable is assigned.
This closes the PHP code.
The only thing that is left to do now is display the $message_confirmation, which can be done like so:
So your whole page will be:
To create an online contact form, you will need two parts.
1) The HTML for the form that is used by your visitors.
2) The PHP server-side code that interprets the form and sends it as an email.
Your online contact form will look something like this:
<form method='post'>
<table>
<tr>
<td>
<label for='from_name'>Your name: </label>
</td>
<td>
<input name='from_name' type='text' />
</td>
</tr>
<tr>
<td>
<label for='from_mail'>e-mail address: </label>
</td>
<td>
<input name='from_mail' type='text' />
</td>
</tr>
<tr>
<td>
<label for='message'>Message:</label>
</td>
<td>
<textarea name='message'></textarea>
</td>
</tr>
<tr>
<td>
</td>
<td>
<input name='submit' id='submit' type='submit' value='Send message' />
</td>
</tr>
</table>
</form>
<table>
<tr>
<td>
<label for='from_name'>Your name: </label>
</td>
<td>
<input name='from_name' type='text' />
</td>
</tr>
<tr>
<td>
<label for='from_mail'>e-mail address: </label>
</td>
<td>
<input name='from_mail' type='text' />
</td>
</tr>
<tr>
<td>
<label for='message'>Message:</label>
</td>
<td>
<textarea name='message'></textarea>
</td>
</tr>
<tr>
<td>
</td>
<td>
<input name='submit' id='submit' type='submit' value='Send message' />
</td>
</tr>
</table>
</form>
So let's take a closer look at the key parts of this:
<form method='post'>
This opens up the form so that the web page knows to treat everything inside as part of the form.
method='post' is used so that the data is sent behind the scenes to the server using the HTTP POST method. The alternative would be to use the HTTP GET method which would make the data visible within the URL. This can be messy, as the user's URL will contain the whole text of the message along with all other submitted information. Also there is a limit to how much data can be sent through GET, whereas POST is not limited.
<label for='from_name'>Your name: </label>
This is a handy little piece of HTML. It will allow the user to click on the words "Your name: " and it will activate the associated input box.
<input name='from_name' type='text' />
This is where the name is entered into the form.
<textarea name='message'></textarea>
This is where the message is entered. Unlike the inputs, this will appear as a box with multiple rows, rather than a single line.
<input name='submit' id='submit' type='submit' value='Send message' />
This is the Submit button. It is a special type of input that will submit the HTML form, according to its method. In this case we chose the POST method. The value will display the words "Send message" onto the button.
Great! That's the HTML sorted. Now onto the PHP...
<?
if($_POST["submit"] == "Send message")
{
$to_address = "your@address.here";
$email_subject = "Subject of the emails";
$email_headers = "Content-type: text/html; charset=iso-8859-1\n";
$email_headers .= "From: ".$_POST["from_name"]."<".$_POST["from_mail"].">\n";
if(mail($to_address, $email_subject, $_POST["message"], $email_headers) == true)
{
$message_confirmation = "Your message has been sent<br/>";
}
else
{
$message_confirmation = "Your message could not be sent<br/>";
}
}
?>
if($_POST["submit"] == "Send message")
{
$to_address = "your@address.here";
$email_subject = "Subject of the emails";
$email_headers = "Content-type: text/html; charset=iso-8859-1\n";
$email_headers .= "From: ".$_POST["from_name"]."<".$_POST["from_mail"].">\n";
if(mail($to_address, $email_subject, $_POST["message"], $email_headers) == true)
{
$message_confirmation = "Your message has been sent<br/>";
}
else
{
$message_confirmation = "Your message could not be sent<br/>";
}
}
?>
<?
This starts the PHP code
if($_POST["submit"] == "Send message")
{
{
This is only called if the user clicked the Submit button with value "Send message"
$to_address = "your@address.here";
$email_subject = "Subject of the emails";
$email_subject = "Subject of the emails";
Defines the email address that messages will be sent to and the subject that will be given to these messages
$email_headers = "Content-type: text/html; charset=iso-8859-1\n";
Choose the character set. This is the default character set which you would normally use in English language. The \n is the newline character.
$email_headers .= "From: ".$_POST["from_name"]."<".$_POST["from_mail"].">\n";
This sets the message as from the person and email address specified. Once again \n is used as a newline character.
.= is used instead of equals on its own, because the header is being added to the existing $email_headers variable.
if(mail($to_address, $email_subject, $_POST["message"], $email_headers) == true)
This runs the mail function and also an if statement that checks if the mail() function was successful or not
{
$message_confirmation = "Your message has been sent<br/>";
}
$message_confirmation = "Your message has been sent<br/>";
}
If the mail function was successful, the above variable is assigned
else
{
$message_confirmation = "Your message could not be sent<br/>";
}
{
$message_confirmation = "Your message could not be sent<br/>";
}
If the mail function failed, the above variable is assigned.
?>
This closes the PHP code.
The only thing that is left to do now is display the $message_confirmation, which can be done like so:
<? echo $message_confirmation; ?>
So your whole page will be:
<?
if($_POST["submit"] == "Send message")
{
$to_address = "your@address.here";
$email_subject = "Subject of the emails";
$email_headers = "Content-type: text/html; charset=iso-8859-1
";
$email_headers .= "From: ".$_POST["from_name"]."<".$_POST["from_mail"].">
";
if(mail($to_address, $email_subject, $_POST["message"], $email_headers) == true)
{
$message_confirmation = "Your message has been sent<br/>";
}
else
{
$message_confirmation = "Your message could not be sent<br/>";
}
}
?>
<html>
<body>
<? echo $message_confirmation; ?>
<form method='post'>
<table>
<tr>
<td>
<label for='from_name'>Your name: </label>
</td>
<td>
<input name='from_name' type='text' />
</td>
</tr>
<tr>
<td>
<label for='from_mail'>e-mail address: </label>
</td>
<td>
<input name='from_mail' type='text' />
</td>
</tr>
<tr>
<td>
<label for='message'>Message:</label>
</td>
<td>
<textarea name='message'></textarea>
</td>
</tr>
<tr>
<td>
</td>
<td>
<input name='submit' id='submit' type='submit' value='Send message' />
</td>
</tr>
</table>
</form>
</body>
</html>
if($_POST["submit"] == "Send message")
{
$to_address = "your@address.here";
$email_subject = "Subject of the emails";
$email_headers = "Content-type: text/html; charset=iso-8859-1
";
$email_headers .= "From: ".$_POST["from_name"]."<".$_POST["from_mail"].">
";
if(mail($to_address, $email_subject, $_POST["message"], $email_headers) == true)
{
$message_confirmation = "Your message has been sent<br/>";
}
else
{
$message_confirmation = "Your message could not be sent<br/>";
}
}
?>
<html>
<body>
<? echo $message_confirmation; ?>
<form method='post'>
<table>
<tr>
<td>
<label for='from_name'>Your name: </label>
</td>
<td>
<input name='from_name' type='text' />
</td>
</tr>
<tr>
<td>
<label for='from_mail'>e-mail address: </label>
</td>
<td>
<input name='from_mail' type='text' />
</td>
</tr>
<tr>
<td>
<label for='message'>Message:</label>
</td>
<td>
<textarea name='message'></textarea>
</td>
</tr>
<tr>
<td>
</td>
<td>
<input name='submit' id='submit' type='submit' value='Send message' />
</td>
</tr>
</table>
</form>
</body>
</html>