...

View Full Version : Help with a Flash Contact Form



98stang
03-01-2009, 12:25 AM
I'm new to this flash and .php thing and I don't know whether this goes into the flash section or the php section. Anways I'm trying to get a flash contact form to work. Here is the AS for the movie clip


onClipEvent(mouseDown){

var senderLoad:LoadVars = new LoadVars();


sender.onRelease = function() {
senderLoad.tf_1 = tf_1.text;
senderLoad.tf_2 = tf_2.text;
senderLoad.tf_3 = tf_3.text;
senderLoad.tf_4 = tf_4.text;
senderLoad.send("contact.php", "_blank", "POST");
}
}


Here is the .php file.


<?PHP







$to = "myemail";
$subject = "Hello, I have a question or comment";
$message = "Name: " . $_POST['tf_1'];
$message .= "\nEmail: " . $_POST['tf_3'];
$message .= "\nState: " . $_POST['tf_4'];
$message .= "\n\nMessage: " . $_POST['tf_2'];


ini_set('SMTP', 'relay-hosting.secureserver.net'); //read u need this here for GoDaddy

mail($to,$subject,$message,$headers);

?>

The host for the website is GoDaddy and they have their own gdform.php file but I have no idea how to incorporate the AS into the .php file. Here is the gdform.php they give you

<?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"]."/");
}


?>

Any help is appreaciated.

gnomeontherun
03-03-2009, 03:04 PM
What do you need help with, and whats the problem?

98stang
03-03-2009, 03:57 PM
The problem is I cannot get the email to work. Nothing gets sent to my email box.

gnomeontherun
03-03-2009, 08:42 PM
http://www.kirupa.com/developer/actionscript/flash_php_email.htm

Check that first and try those techniques.

Then verify that your information is getting sent to PHP.

So instead of having it mail have it echo out the variables.


<?php
echo $_POST['tf_1'];
echo $_POST['tf_3'];
echo $_POST['tf_4'];
echo $_POST['tf_2'];

?>

And report back if the variables are getting sent to PHP. That way I know if its PHP or AS.

98stang
03-03-2009, 10:39 PM
Well I looked on another forum and a person told me to do this



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
}

it's "_root.movieclipname.textinputname.text." Reason he said this was that my input text boxes each sit on a movie clip, meaning there's 4 movie clips.

Also on that website, Can I just rename the instance fields instead of selecting them all to make one movie clip?

gnomeontherun
03-04-2009, 10:05 AM
Lets focus on getting the PHP to work first, as it appears not to be working. Have you checked with your host on the proper setup? Do you really need that set_int thing? Or is something else missing?

98stang
03-04-2009, 05:12 PM
well the host is GoDaddy. I read on another forum where a user had GoDaddy and GoDaddy sent them an email saying to put that ini_set into the .php file. I pretty sure the .php file works (mine, not the GoDaddy one) because when I open the .php file, I get an email with the subject and such. It just doesn't show what user typed.

gnomeontherun
03-05-2009, 12:18 AM
Well test the PHP with test variables to verify that it is sending emails first. I want to know that is working before we proceed.

98stang
03-05-2009, 01:42 AM
the .php is working (tested it) this is the file (it's coded a little different)


<?PHP

include_once("contact.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');

mail($to,$subject,$message);

?>

gnomeontherun
03-05-2009, 09:53 AM
Ok good, then we can work on the AS.

First, check that you have variable names (Not Instances!) and these should match your PHP like theName and theEmail. Then you can use the code from the other person, or just this should also work since you will have the variables set and won't need to grab the text field values.


on (release) {
loadVariablesNum ("contact.php", 0, "POST");
}
}

98stang
03-05-2009, 03:23 PM
it still sending the email without what the user typed. I check the variable names and they are correct. Also checked the names on the .php file and they are correct.

gnomeontherun
03-06-2009, 10:38 AM
Are you using this script or what I said?


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
}

What kind of form element is theMessage? Are you sure it is within a movieClip called Message with the instance name of txtMessage?

By the way, you should always put ; at the end of each set of commands.

98stang
03-10-2009, 04:16 PM
basically the input boxes are sitting on top of the movie clips. Also does it matter the the movie clips(the ones under the input boxes) are sitting on a movie clip?


Here is the website. Click on Contact to see the form I'm talking about.
http://www.wantedeyewear.com

gnomeontherun
03-10-2009, 10:57 PM
Yes but what is the code you finally settled on using?

98stang
03-17-2009, 03:40 PM
problem solved

mccreadyphoto
08-24-2009, 06:14 PM
Can you tell me how you fixed it? I am having the same problem :(



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum