Welcome, Guest. Please login or register.
Did you miss your activation email?
05/21/12, 04:25
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  General
| |-+  Flash 8 (Moderators: Jorge Solis, ..:: Mazhar Hasan ::.., Andresss)
| | |-+  how to redirect to another page after sending an enquiry?
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: how to redirect to another page after sending an enquiry?  (Read 2800 times)
-shamarque-
Jr. Programmer
**
Posts: 53

shamarque@hotmail.com shamarque@yahoo.com shamarque
View Profile WWW Email
« on: 09/10/06, 20:33 »

Hi all.

i would like to ask, how to redirect to another page after user succesfully send their enquiry form?

the actionscript for the button is;

Code:
on (release) {
//Creates a LoadVars and get values from the form
mylv = new LoadVars();
myreply = new LoadVars();
mylv.email = email;
mylv.name = name;
mylv.occupational = occupational.selectedItem.data;
mylv.company = company;
mylv.address = address;
mylv.country = country.selectedItem.data;
mylv.zipcode = zipcode;
mylv.tel = tel;
mylv.fax = fax;
mylv.message = message;
mylv.recip = recip;
mylv.sics = sics.selected;
mylv.edu = edu.selected;
mylv.it = it.selected;
mylv.business = business.selected;
mylv.project = project.selected;
mylv.hr = hr.selected;
mylv.contactBy = contactBy.selectedItem.data;
//Show success or fails message
myreply.onLoad = function (success) {
if(!success)
_parent.status = 'sending failed';
else
_parent.status = this.status;
};
mylv.sendAndLoad('sendmail.php', myreply, 'POST');
_parent.status = 'sending now ...';
}

i try adding 1 line to the script (arrow), but if there's an error on the form which user need to correct their entry, it still will redirect it to the page.

Code:
myreply.onLoad = function (success) {
if(!success)
_parent.status = 'sending failed';
else
_parent.status = this.status;
_parent.gotoAndPlay(101);      <------------------------------------------------------------------
};
}


the php code for this is form is

Code:
<?php
// list all vars to be expected from the movie
$vars = array("name""occupational""email""message""recip""company""address""country""zipcode""tel""fax""contactBy");
// and import them into the script
foreach($vars as $var)
if(isset($_POST[$var]))
$$var $_POST[$var];
else
$$var '';

// check variables
if(strlen($name) < 3)
die("&status=please enter a real name&");
if(!
eregi('^([a-z0-9\._-])+@([^\.]+\.[^\.]+)'$email$matched))
die("&status=please enter a correct email address&");
else if(!
getmxrr($matched[2], $mxrr))
die("&status=your mail server does not seem to exist&");

// where to send it
// remove or configure one of the two code blocks
$red $_SERVER['/test/sf2/mailform.swf'];

// ***** or one fixed recipient ******
$recip "admin@website.com";
//****  end fixed recipient *******


// build up message
// this code for any multiline text fields
$message str_replace("\r""\n"$message);
// info vars
$sender $_SERVER[REMOTE_ADDR];

if(
$sics == 'true')
{
$sicsInfo "Company Sdn. Bhd.";
}
else if(
$sics == 'false')
{
$sicsInfo " ";
}

if(
$edu == 'true')
{
$eduInfo "Education Consulting";
}
else if(
$edu == 'false')
{
$eduInfo " ";
}

if(
$it == 'true')
{
$itInfo "IT and E-learning Solution and Framework";
}
else if(
$it == 'false')
{
$itInfo " ";
}

if(
$business == 'true')
{
$businessInfo "Business Planning and Financial Forecasting";
}
else if(
$business == 'false')
{
$businessInfo " ";
}

if(
$project == 'true')
{
$projectInfo "Project Management";
}
else if(
$project == 'false')
{
$projectInfo " ";
}

if(
$hr == 'true')
{
$hrInfo "HR Strategic Management and Planning Services";
}
else if(
$hr == 'false')
{
$hrInfo " ";
}

// you can rearrange this - just do not add or remove quotes
$mailbody "Enquiry form sent by
Name: $name
Occupational: $occupational
Email: $email

Company: $company
Address: $address
Country: $country
Zip Code/Postal Code: $zipcode
tel: $tel
fax: $fax

I want to know information about:

$sicsInfo
$eduInfo
$itInfo
$businessInfo
$projectInfo
$hrInfo

Specific enquiry:
$message

How would you like to be contacted: $contactBy
-------
sender's ip: $sender"
;

// send it off
// note - if you omit the last part, a few servers do not send mail at all,
// but most would show strange senders like nobody@server17.hostingcompany.com
mail($recip"Enquiry Form"$mailbody"From: admin@webserver.com"$red);

// and tell visitor
print "&status=Enquiry sent - we will be in touch with you shortly&";
?>


How to redirect it to other page if the enquiry form succesfully send?

for your information, i follow and change code from flash-db e-mail tutorial. hopefully i post my problem in a right board.

thank you in advance.

-shamarque-
Logged

-Success Is A Ladder That Cannot Be Climbed With Your Hands In Your Pocket-
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« Reply #1 on: 09/11/06, 02:13 »

Don't forget the brackets:

if(!success){
  
_parent.status 'sending failed';
} else {
  
_parent.status this.status;
  
_parent.gotoAndPlay(101);
}

Jorge
Logged

-shamarque-
Jr. Programmer
**
Posts: 53

shamarque@hotmail.com shamarque@yahoo.com shamarque
View Profile WWW Email
« Reply #2 on: 09/11/06, 04:28 »

hi jorge,

thank you for the replied jorge.

i already change it base on what u ask me to do.. but the problem still the same.

eventhough i didnt fill anything in "name" fill, its still will redirect the page to frame 101.

thank you in advance.
Logged

-Success Is A Ladder That Cannot Be Climbed With Your Hands In Your Pocket-
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« Reply #3 on: 09/11/06, 04:52 »

Sorry, didn't read your script completely. You're validating nothing. I.e, to check the name (at least 3 letters) use:

on (release) {
//Check data
if(name.length<3) {
  
error "Should fill the name" //error is a textfield on stage
  
return
}
... and 
all the textfield you want to check
//Creates a LoadVars and get values from the form
mylv = new LoadVars();

Jorge
Logged

-shamarque-
Jr. Programmer
**
Posts: 53

shamarque@hotmail.com shamarque@yahoo.com shamarque
View Profile WWW Email
« Reply #4 on: 09/12/06, 02:33 »

i tried it already Jorge...

but it's not working... still the same.. even i did not fill the name.. it still redirect it to frame 101.

on (release) {
   //Check data
   if (mylv.name.length<3) {
      error = "Should fill the name";
      //error is a textfield on stage
      return;
   }
   //Creates a LoadVars and get values from the form 
   mylv = new LoadVars();
   myreply = new LoadVars();
   mylv.email = email;
   mylv.contactBy = contactBy.selectedItem.data;

   //Show success or fails message
   myreply.onLoad = function(success) {
      
      if (!success) {
         _parent.status = 'sending failed';
      } else {
         _parent.status = this.status;
         _parent.gotoAndPlay(101);
      }
   };
   mylv.sendAndLoad('sendmail.php', myreply, 'POST');
   _parent.status = 'sending now ...';
}
« Last Edit: 09/12/06, 21:27 by -shamarque- » Logged

-Success Is A Ladder That Cannot Be Climbed With Your Hands In Your Pocket-
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« Reply #5 on: 09/12/06, 06:41 »

My code:

if(name.length<3)

Yours

if (mylv.name.length<3)

I use a reference to the variable in the textfield, not to the LoadVars object

Jorge
Logged

-shamarque-
Jr. Programmer
**
Posts: 53

shamarque@hotmail.com shamarque@yahoo.com shamarque
View Profile WWW Email
« Reply #6 on: 09/12/06, 21:24 »

hi Jorge..

i'm sorry... i past the wrong code on the board... my bad. Sad Cry

but.. i tried everything.. still wont work...

on (release) {
   //Check data
   if (name.length<3) {
      error = "Should fill the name";
      //error is a textfield on stage
      return;
   }

   //Creates a LoadVars and get values from the form 
   mylv = new LoadVars();
   myreply = new LoadVars();
   mylv.email = email;
   mylv.contactBy = contactBy.selectedItem.data;

   //Show success or fails message
   myreply.onLoad = function(success) {
     
      if (!success) {
         _parent.status = 'sending failed';
      } else {
         _parent.status = this.status;
         _parent.gotoAndPlay(101);
      }
   };
   mylv.sendAndLoad('sendmail.php', myreply, 'POST');
   _parent.status = 'sending now ...';
}
« Last Edit: 09/12/06, 21:29 by -shamarque- » Logged

-Success Is A Ladder That Cannot Be Climbed With Your Hands In Your Pocket-
-shamarque-
Jr. Programmer
**
Posts: 53

shamarque@hotmail.com shamarque@yahoo.com shamarque
View Profile WWW Email
« Reply #7 on: 09/12/06, 21:36 »

i also tried something like this... its not working at all...

on (release) {
   //Creates a LoadVars and get values from the form 
   mylv = new LoadVars();
   myreply = new LoadVars();
   mylv.email = email;
   mylv.name = name;
   
   //Show success or fails message
   myreply.onLoad = function(success) {
      
      if (!email.length || email.indexOf("@") == -1 || email.indexOf(".") == -1) {
         status = "Please enter a valid E-mail address.";
      } else if (name.length<3) {
         status = "Please Enter your name before Sending.";
      } else {
         mylv.sendAndLoad('sendmail.php', myreply, 'POST');
         _parent.status = 'sending now ...';
      }
      
      if (_parent.name.text != "" && _parent.email.text != "") {
         _parent.gotoAndPlay(101);
      }
   };
}

thank you in advance.
Logged

-Success Is A Ladder That Cannot Be Climbed With Your Hands In Your Pocket-
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« Reply #8 on: 09/13/06, 01:45 »

The validation should be BEFORE sending the data, not in the onLoad handler. Seems that you don't understand the LoadVars mechanism. Check the saving data tutorial, where you can see also a validation example: http://www.flash-db.com/Tutorials/saving/savingData.php?page=2
In the example I use the recomended text property of a named textfield, since using vars in textfield is deprecated since Flash 6

Jorge

Logged

-shamarque-
Jr. Programmer
**
Posts: 53

shamarque@hotmail.com shamarque@yahoo.com shamarque
View Profile WWW Email
« Reply #9 on: 09/13/06, 02:39 »

thanks Jorge..

i'll study it first.
Logged

-Success Is A Ladder That Cannot Be Climbed With Your Hands In Your Pocket-
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
anything