Need Help with a Flash Contact form(Problem solved)

  • 98stang
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Mar 03, 2009
  • Posts: 11
  • Status: Offline

Post March 3rd, 2009, 7:59 am

I'm trying to get a flash contact form to work but it will not pass the variables to the .php file. The website is be hosted by GoDaddy and it's on a Linux Server. I've searched through the forums and looked at other topics but have had zero luck with it. Here is the code.

Update: I got an email but next it everything, it said undefined.

The AS
Code: [ Select ]
on (release) {
 
      loadVariablesNum("contact.php", 0, "POST");
      theName = Name.text
      theState = State.text
      theEmail = Email.text
      theMessage = Message.text
     
     
   }
  1. on (release) {
  2.  
  3.       loadVariablesNum("contact.php", 0, "POST");
  4.       theName = Name.text
  5.       theState = State.text
  6.       theEmail = Email.text
  7.       theMessage = Message.text
  8.      
  9.      
  10.    }



Here is the .php:
Code: [ Select ]
<?PHP
 
 
 
 
if (isset($HTTP_POST_VARS)) {
 
$theName = $HTTP_POST_VARS["theName"];
$theState = $HTTP_POST_VARS["theState"];
$theEmail = $HTTP_POST_VARS["theEmail"];
$theMessage = $HTTP_POST_VARS["theMessage"];
}
 
$to = "myemail";
$subject = "Hello, I have a question or comment";
$message .= "Name: " ."$theName\n\n";
$message .= "State: " ."$theState\n\n";
$message .= "Email: " ."$theEmail\n\n";
$message .= "Message: " ."$theMessage\n\n";
 
ini_set('SMTP', 'relay-hosting.secureserver.net'); //read u need this for GoDaddy
 
mail($to,$subject,$message);
 
?>
 
  1. <?PHP
  2.  
  3.  
  4.  
  5.  
  6. if (isset($HTTP_POST_VARS)) {
  7.  
  8. $theName = $HTTP_POST_VARS["theName"];
  9. $theState = $HTTP_POST_VARS["theState"];
  10. $theEmail = $HTTP_POST_VARS["theEmail"];
  11. $theMessage = $HTTP_POST_VARS["theMessage"];
  12. }
  13.  
  14. $to = "myemail";
  15. $subject = "Hello, I have a question or comment";
  16. $message .= "Name: " ."$theName\n\n";
  17. $message .= "State: " ."$theState\n\n";
  18. $message .= "Email: " ."$theEmail\n\n";
  19. $message .= "Message: " ."$theMessage\n\n";
  20.  
  21. ini_set('SMTP', 'relay-hosting.secureserver.net'); //read u need this for GoDaddy
  22.  
  23. mail($to,$subject,$message);
  24.  
  25. ?>
  26.  


Also, GoDaddy gives you their own .php file but I have no idea how to incorporate the flash code into the .php file. Here is their .php file.

Code: [ Select ]
<?php
$request_method = $_SERVER["REQUEST_METHOD"];
if($request_method == "GET"){
$query_vars = $_GET;
} elseif ($request_method == "POST"){
$query_vars = $_POST;
}
reset($query_vars);
$t = date("U");
 
$file = $_SERVER['DOCUMENT_ROOT'] . "/../data/gdform_" . $t;
$fp = fopen($file,"w");
while (list ($key, $val) = each ($query_vars)) {
fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\n");
fputs($fp,"$val\n");
fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\n");
if ($key == "redirect") { $landing_page = $val;}
}
fclose($fp);
if ($landing_page != ""){
header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");
} else {
header("Location: http://".$_SERVER["HTTP_HOST"]."/");
}
 
 
?>
  1. <?php
  2. $request_method = $_SERVER["REQUEST_METHOD"];
  3. if($request_method == "GET"){
  4. $query_vars = $_GET;
  5. } elseif ($request_method == "POST"){
  6. $query_vars = $_POST;
  7. }
  8. reset($query_vars);
  9. $t = date("U");
  10.  
  11. $file = $_SERVER['DOCUMENT_ROOT'] . "/../data/gdform_" . $t;
  12. $fp = fopen($file,"w");
  13. while (list ($key, $val) = each ($query_vars)) {
  14. fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\n");
  15. fputs($fp,"$val\n");
  16. fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\n");
  17. if ($key == "redirect") { $landing_page = $val;}
  18. }
  19. fclose($fp);
  20. if ($landing_page != ""){
  21. header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");
  22. } else {
  23. header("Location: http://".$_SERVER["HTTP_HOST"]."/");
  24. }
  25.  
  26.  
  27. ?>
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post March 3rd, 2009, 7:59 am

  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Joined: Jul 11, 2005
  • Posts: 1828
  • Loc: In the Great White North
  • Status: Offline

Post March 3rd, 2009, 11:30 am

I don't think its your php. Its likely the way you have your AS written that it can't find the actual data in the form fields.

Because of the way pathing works in Flash your code is looking for text fields INSIDE the button. Unless told otherwise Flash always uses the current clip as an implied "this" before an instance name.

so in your case Flash is looking for buttonInstance.Name. So if your text field is on the main timeline your code should be
Code: [ Select ]
on (release) {
 
       loadVariablesNum("contact.php", 0, "POST");
       theName = _root.Name.text
       theState = _root.State.text
       theEmail = _root.Email.text
       theMessage = _root.Message.text
}
  1. on (release) {
  2.  
  3.        loadVariablesNum("contact.php", 0, "POST");
  4.        theName = _root.Name.text
  5.        theState = _root.State.text
  6.        theEmail = _root.Email.text
  7.        theMessage = _root.Message.text
  8. }


That should fix your "undefined" issue. I would however start learning to place your code on the timeline instead of attaching it to an object.
If at first you don't succeed F1... If that doesn't work try Google!
//// Designer, Developer & Teacher - Interactive, Motion and 3D \\\\
Portfolio at WhenImNotSleeping.com
  • 98stang
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Mar 03, 2009
  • Posts: 11
  • Status: Offline

Post March 3rd, 2009, 12:34 pm

First, I want to thank you graphixboy for responding(you're the first to do so and I've posted this on 4 forums).

You said something about putting on a timelines and I've had no experience with timelinies being that I don't know flash or .php that well. The Object I have it on is a movie clip that is used through the website so putting on the timeline would affect each part that movie clip it is placed at. Is there any other code I could use to make this work?
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Joined: Jul 11, 2005
  • Posts: 1828
  • Loc: In the Great White North
  • Status: Offline

Post March 3rd, 2009, 12:41 pm

did you try what I posted above? Leave your code as is but put the path to the dynamic text field in front of the instance name. That should solve your problem. The timeline comment was for future reference to help you write better code.
If at first you don't succeed F1... If that doesn't work try Google!
//// Designer, Developer & Teacher - Interactive, Motion and 3D \\\\
Portfolio at WhenImNotSleeping.com
  • 98stang
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Mar 03, 2009
  • Posts: 11
  • Status: Offline

Post March 3rd, 2009, 12:56 pm

could you give me an example of what you mean?
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Joined: Jul 11, 2005
  • Posts: 1828
  • Loc: In the Great White North
  • Status: Offline

Post March 3rd, 2009, 1:03 pm

look at my original post. I'm taking about adding the stuff in red to your existing code. However mine is assuming that your text fields are sitting on the main stage and not inside a movieclip.
If at first you don't succeed F1... If that doesn't work try Google!
//// Designer, Developer & Teacher - Interactive, Motion and 3D \\\\
Portfolio at WhenImNotSleeping.com
  • 98stang
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Mar 03, 2009
  • Posts: 11
  • Status: Offline

Post March 3rd, 2009, 1:05 pm

Yes they are each sitting in it's own movie clip.
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Joined: Jul 11, 2005
  • Posts: 1828
  • Loc: In the Great White North
  • Status: Offline

Post March 3rd, 2009, 1:14 pm

ok then you would do _root.movieclipname.textfielddname.text
If at first you don't succeed F1... If that doesn't work try Google!
//// Designer, Developer & Teacher - Interactive, Motion and 3D \\\\
Portfolio at WhenImNotSleeping.com
  • 98stang
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Mar 03, 2009
  • Posts: 11
  • Status: Offline

Post March 3rd, 2009, 1:22 pm

Ok the email is coming but the fields are blank. It's just:

Name:
Email:
State:
Message:



here's what I have so far

Code: [ Select ]
on (release) {

     loadVariablesNum("contact.php", 0, "POST");
     theName = _root.Name.txtName.text
     theState = _root.State.txtState.text
     theEmail = _root.Email.txtEmail.text
     theMessage = _root.Message.txtMessage.text
}
  1. on (release) {
  2.      loadVariablesNum("contact.php", 0, "POST");
  3.      theName = _root.Name.txtName.text
  4.      theState = _root.State.txtState.text
  5.      theEmail = _root.Email.txtEmail.text
  6.      theMessage = _root.Message.txtMessage.text
  7. }
  • devilwood
  • Silver Member
  • Silver Member
  • User avatar
  • Joined: Nov 18, 2007
  • Posts: 429
  • Status: Offline

Post March 3rd, 2009, 4:09 pm

Here's how I build forms in flash

first the flash: Your input fields will take up frame 1 and 2, and frame 3 will be a success page with a back button to frame 1. A submit button will gotoAndStop(2); so on frame 2 you will replace the submit button with a LOADING... image or something. Also place a dynamic textfield with instancename of alert on frame 1.

Code: [ Select ]
// on frame 2
myvars = new LoadVars();
myvars.name = txtName.text;
myvars.email = txtEmail.text;
myvars.state = txtState.text;
myvars.msg = txtMessage.txt;
myvars.onLoad = getembackjojo;
myvars.sendAndLoad("contact.php", myvars, "POST");
function getembackjojo() {
    var checkThis = myvars.corpPor;
    if (checkThis == "1") {
                 // success
        gotoAndStop(3);
    } else if (checkThis == "2") {
                alert.text = "Error: Could not send email. Check email address.";
        gotoAndStop(1);
    } else if (checkThis == "3") {
                alert.text = "Error: next error explanation like name is missing.";
        gotoAndStop(1);
            }
}
  1. // on frame 2
  2. myvars = new LoadVars();
  3. myvars.name = txtName.text;
  4. myvars.email = txtEmail.text;
  5. myvars.state = txtState.text;
  6. myvars.msg = txtMessage.txt;
  7. myvars.onLoad = getembackjojo;
  8. myvars.sendAndLoad("contact.php", myvars, "POST");
  9. function getembackjojo() {
  10.     var checkThis = myvars.corpPor;
  11.     if (checkThis == "1") {
  12.                  // success
  13.         gotoAndStop(3);
  14.     } else if (checkThis == "2") {
  15.                 alert.text = "Error: Could not send email. Check email address.";
  16.         gotoAndStop(1);
  17.     } else if (checkThis == "3") {
  18.                 alert.text = "Error: next error explanation like name is missing.";
  19.         gotoAndStop(1);
  20.             }
  21. }



For PHP:

Code: [ Select ]

$name = trim($_POST['name']);
$e = trim($_POST['email']);
$state = trim($_POST['state']);
$msg1 = trim($_POST['msg']);


if ($name == "") {
$var = "&corpPor=3";
echo $var;
exit();
}


if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $e)) {
$from = "from: Your Email<me@me.com>\n";
$from .= "Return-Path: Reply to me<reply@me.com>\n";
$from .= "X-Mailer: PHP/" . phpversion() . "\n"; 
$from .= "X-Priority: 1";
$emailit = "Name: $name \n Email: $e \n State: $state \n Msg: $msg1 ";
$subject= "Subject";
mail("$e","$subject","$emailit","$from");
$var = "&corpPor=1";
echo $var;
} else {
$var = "&corpPor=2";
echo $var;
exit();
}
  1. $name = trim($_POST['name']);
  2. $e = trim($_POST['email']);
  3. $state = trim($_POST['state']);
  4. $msg1 = trim($_POST['msg']);
  5. if ($name == "") {
  6. $var = "&corpPor=3";
  7. echo $var;
  8. exit();
  9. }
  10. if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $e)) {
  11. $from = "from: Your Email<me@me.com>\n";
  12. $from .= "Return-Path: Reply to me<reply@me.com>\n";
  13. $from .= "X-Mailer: PHP/" . phpversion() . "\n"; 
  14. $from .= "X-Priority: 1";
  15. $emailit = "Name: $name \n Email: $e \n State: $state \n Msg: $msg1 ";
  16. $subject= "Subject";
  17. mail("$e","$subject","$emailit","$from");
  18. $var = "&corpPor=1";
  19. echo $var;
  20. } else {
  21. $var = "&corpPor=2";
  22. echo $var;
  23. exit();
  24. }



Hope that helps. Let us know if you have any problems.
  • devilwood
  • Silver Member
  • Silver Member
  • User avatar
  • Joined: Nov 18, 2007
  • Posts: 429
  • Status: Offline

Post March 3rd, 2009, 5:03 pm

Sorry, in flash each frame should have a stop();
  • 98stang
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Mar 03, 2009
  • Posts: 11
  • Status: Offline

Post March 10th, 2009, 8:17 am

still needing help with this....
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Joined: Jul 11, 2005
  • Posts: 1828
  • Loc: In the Great White North
  • Status: Offline

Post March 10th, 2009, 8:47 am

What do you have so far?
If at first you don't succeed F1... If that doesn't work try Google!
//// Designer, Developer & Teacher - Interactive, Motion and 3D \\\\
Portfolio at WhenImNotSleeping.com
  • 98stang
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Mar 03, 2009
  • Posts: 11
  • Status: Offline

Post March 10th, 2009, 10:22 am

This is what I have so far:

Code: [ Select ]
on (release) {
 
      loadVariablesNum("contact.php", 0, "POST");
       theName = _root.Name.txtName.text;
       theState = _root.State.txtState.text;
       theEmail = _root.Email.txtEmail.text;
       theMessage = _root.Message.txtMessage.text;
}
  1. on (release) {
  2.  
  3.       loadVariablesNum("contact.php", 0, "POST");
  4.        theName = _root.Name.txtName.text;
  5.        theState = _root.State.txtState.text;
  6.        theEmail = _root.Email.txtEmail.text;
  7.        theMessage = _root.Message.txtMessage.text;
  8. }


The input boxes are on top of the movie clips, not inside them. Should I remove the movie clips from the code? Also have variables set too (theMessage, theState, theName, theEmail) but the loadVariablesNum won't pass them to the .php

here is the .php

Code: [ Select ]
<?PHP
 
 
 
 
if (isset($HTTP_POST_VARS)) {
 
$Name = $HTTP_POST_VARS["theName"];
$State = $HTTP_POST_VARS["theState"];
$Email = $HTTP_POST_VARS["theEmail"];
$Message = $HTTP_POST_VARS["theMessage"];
}
 
$to = "myemail";
$subject = "Hello, I have a question or comment";
$message .= "Name: " ."$Name\n\n";
$message .= "State: " ."$State\n\n";
$message .= "Email: " ."$Email\n\n";
$message .= "Message: " ."$Message\n\n";
 
ini_set('SMTP', 'relay-hosting.secureserver.net');
 
mail($to,$subject,$message);
 
?>
  1. <?PHP
  2.  
  3.  
  4.  
  5.  
  6. if (isset($HTTP_POST_VARS)) {
  7.  
  8. $Name = $HTTP_POST_VARS["theName"];
  9. $State = $HTTP_POST_VARS["theState"];
  10. $Email = $HTTP_POST_VARS["theEmail"];
  11. $Message = $HTTP_POST_VARS["theMessage"];
  12. }
  13.  
  14. $to = "myemail";
  15. $subject = "Hello, I have a question or comment";
  16. $message .= "Name: " ."$Name\n\n";
  17. $message .= "State: " ."$State\n\n";
  18. $message .= "Email: " ."$Email\n\n";
  19. $message .= "Message: " ."$Message\n\n";
  20.  
  21. ini_set('SMTP', 'relay-hosting.secureserver.net');
  22.  
  23. mail($to,$subject,$message);
  24.  
  25. ?>
  • 98stang
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Mar 03, 2009
  • Posts: 11
  • Status: Offline

Post March 12th, 2009, 8:54 am

pm'ed the .fla file to you graphixboy
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post March 12th, 2009, 8:54 am

Post Information

  • Total Posts in this topic: 16 posts
  • Users browsing this forum: No registered users and 29 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.