

This tutorial is to teach you how to write a script to record the last visit of your visitor and displays it upon their return. If this is their first visit, then a welcome message is displayed. Otherwise the message with last time visit will be displayed.
You need to make use of cookie, which is stored on the visitor’s computer. Each time the same computer requests a page; it will send the cookie too.
In this example, I create a cookie with an expiration date of 1 day and checks to see if cookie is set, or it has been greater or equal to 1 day.
Create and Store a Cookie
Firstly, you need to create a function that stores the cookie name, the value of the cookie, and the number of days until the cookie expires in a variable.
(more…)
|
No Comments »
Sometimes we to do some validation that allow to process user input client side. This is because it will save the user time if he/she is notified of errors before submitting the form. This is the sample of my simple JavaScript code for validating URL, using regular expression:
<script language=”javascript”>
function URLValidate(v) {
var regex = /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/;
alert(regex.test(v));
}
</script>
<body>
<form>
<input type=”text” size=”20″ id=”url”/>
<input type=”button” value=”Validate” onClick=”URLValidate(document.getElementById(’url’).value);”/>
</form>
</body>



However, this example does not cover all the cases, it only can validate the URL start with http://, if the URL start with www, then it will return false. By right, it should not be like that.
(more…)
|
No Comments »
In this Flash tutorial you will learn how to use write Actionscript to make a simple hit test, this is the fundamental thing that you need to know before create any flash game.
First of all, do you understand what is Hit Test? Hit Test enables you to ask Flash “Is this movie clip in contact with other movie clip?
My Basic Code On Hit Test (Collision Detection)
In order to create a collision, you need to have at least 2 object. Create a circle and convert it into movie clip. Then, give the instance name called ball1. Create the another circle and repeat the step as ball1 but this time give the instance name called ball2.
Next, remember to create the dynamic text which to display the message whether the ball is in contact with each other. Display “Collision Detected” once 2 ball is in contact else will display ” No Collision“.

Then, select on the ball1 and press F9. The Object Actions panel will appear. After that, copy and paste the following code into that panel.
(more…)
|
No Comments »
Create an Upload File Form
This is a tutorial regarding uploading file using PHP. You need to build a HTML form that lets users to select a file to upload. See my sample code for a more details at forms.

There are a couple of important things to note:
- An upload form is another type of input form, simply set the input type attribute to file.
- Set the attribute of form called enctype to “multipart/form-data”. This means that the form require the contents of a file, to be uploaded.
(more…)
|
No Comments »