Web Development Logs
Find articles, news and reviews about latest technologies.


Welcome Guest !
please login or register a new free account.


Home | Archives | Submit Article | Top Rated | Advance Search | Contacts Us | Rss Feeds

    Main Categories
» Free downloads
» General Blog
» Google Adsense
» Scripting languages
» Search Engines
» Web Designing

  More Options
» Most read articles
» Most rated articles

   Subscription
Subscribe now and receive free articles and updates instantly.
» Your name » Your Email

titles description    advance search
Published : April 29, 2006 | Author : Ali Roman
Category : Scripting languages | Total Views : 6507 | Rating :

  
This tutorial will demonstrate how to make a very simple contact form using SWiSH MAX.

Level : Intermediate

I assume that you can make input boxes and know how to use variables. If you dont know how to use variables and how to make input boxes then please read the following tutorial before reading this tutotial.

Inputbox to TEXT file
and
Varables

STEPS TO BE PERFORMED

1. Make 4 input boxes with the following variable names

nameVar
emailVar
subjectVar
msgVar


2. Make a dynamic text box which will display status and errors with variable name errormessage

3. Make a button with name Clear Form and paste the following code on its action.

on (release) {
nameVar="";
emailVar="";
subjectVar="";
msgVar="";
}

This will clear all the text you have entered in your input text boxes.

4. Make a button with name Send and paste the following code on
its action.

on (release) {
    if((nameVar=="")||(emailVar=="")||(subjectVar=="")||(msgVar=="")){
        errormessage="Please fill all the fields";
    }
    else {
        errormessage="Sending....";
        send="yes";
        this.loadVariables("contact.php",'POST');
        nameVar="";
        emailVar="";
        subjectVar="";
        msgVar="";
    }
}

Description

A. Explanining this part of code

if((nameVar=="")||(emailVar=="")||(subjectVar=="")||(msgVar=="")){
    errormessage="Please fill all the fields";
}


This part of the code checks wether all input boxes are filled or not. In the above
code we have used || logical operator. For more details about logical operators please read the following tutorial. Read Tutorial

B. Explaining the following part of code.

else {
    errormessage="Sending....";
    send="yes";
    this.loadVariables("contact.php",'POST');
    send="no"
    nameVar="";
    emailVar="";
    subjectVar="";
    msgVar="";
}

errormessage="Sending...."; = this line will display the message until your email
has been sent.
send="yes"; = in this line we are putting a new value "YES" to SEND variable, we are
doing this becuase we will check this variable in our PHP file, that is SEND button pressed and all fields were given, if so then send email to the given email address in contact.php file.

this.loadVariables("contact.php",'POST'); = in this line we are loading variables from/to contact.php file which we will be making in our next step. It will send variables (name,email,subject and message) to that PHP file.

5. On frame number 1 of your main time, put the following code on its action

onFrame (1) {
    nameVar="";
    emailVar="";
    subjectVar="";
    msgVar="";
}

This means that there is no text in your input text boxes when you see your movie for the first time.

Everywhere you placed some code on an object (texbox) don't forget to checkmark the TARGET box !

6. Open notepad or any text editor and paste the following code into it

<?
    if ($send=="yes") {
       $to = "YouName@YourDomain.com";
       $subject = "$subjectVar";
       $body .= "$msgVar";
       $from = "$nameVar";
       $tfrom = "From: <$emailVar>";
       mail($to,$subjectVar,$msgVar,$tfrom);
    }
   echo "&errormessage=Email has been sent&";
?>


save this file as contact.php.
here is the preview of the example included in this tutorial

user posted image


NOTE : Dont forget to change the email address in CONTACT.PHP file.
Just input your email address, replace YouName@YourDomain.com with yuor email address.

YOU ARE DONE !

Save you SWI file to contact.swf and export it. Upload contact.swf, contact.html and contact.php to any directory and check it.

REMEMBER : You can use it in any level, means in any sprite or sub sprite. It will work fine.

Download Example File

if you have any questions, please feel free to ask and discuss. I hope this is really handy tutorial can is useful.
best regards

Ali Roman..




1 2 3 4 5
please rate this article     Poor
Excellent    
Most viewed articles in Scripting languages category

Retrieving data from MySQL database using php
Creating simple contact form using swishmax and php
Creating dynamic combo list with PHP and MySQL
Creating simple percentage preloader with swishmax
Saving data to a text file with swishmax and php
Most recent articles in Scripting languages category

Saving data to a text file with swishmax and php
Creating dynamic combo list with PHP and MySQL
Retrieving data from MySQL database using php
Establishing connection with MySQL using php
Creating table using MySQL database

 Visitor's Comments !

there are no comments...


    Random Pick
Shape tweening is a method in which you convert any shape to any other shape, for example a rectangle will be converted to a circle in the following example. Its pretty easy to morph different shapes in Flash.

    Statistics
» Total Articles
72
» Total Authors
96
» Total Views
116306
» Total categories
6

Delete cookies set by this site | Top   

Article Manager by Flaxweb
Copyright 2006 © Flax Article Manager v1.1