PDA

View Full Version : PHP in SWF problem!


markoman
1-8-06, 08:18 AM
The trubles begun 2 or 3 months ago

the script (mailform in php) works fine

<?

$mymail = "myemail@mail.com";
mail("$mymail", "",
"
Email: $email
");

?>

in the flash i use loadVariables("mailform.php", "", "POST");

but the problem is that the script send mail without typed e-mail in .swf file.
In swf file i use input text and var: for input text email.

whats the problem here, it used to work fine... the same thing works well on other Webservers (not powweb)

do i need install something on my webpage or whats the issue, please help!

oatesj77
1-9-06, 05:14 AM
you didn't post a lot of information, so not quite sure where your problem might be. check that your variables are still okay in your flash file, then republish and upload in "binary mode" not ascii. sometimes there are problems with swf's uploaded in ascii rather than binary mode. also check the path to your php page to be sure it has not changed. if that's not the problem, post your actionscript and the code you use in your php page and i'll see if i can figure out what the problem is.

here is the code i use in my php page;

<?php
$sendTo = "xyz@site.com";
$subject = "Message from Site.com";

$headers = "From: " . $_POST["name"];
$headers .= "<" . $_POST["email"] . ">\r\n";
$headers .= "Reply-To: " . $_POST["email"] . "\r\n";
$headers .= "Return-Path: " . $_POST["email"];
$message = $_POST["message"];

mail($sendTo, $subject, $message, $headers);
?>

the above depends on what variables you are sending from your swf, and it works on my site, so there isn't anything you need to upload or change with your account.

clock109
1-17-06, 05:36 PM
With out hijacking this thread too much, I wanted to thank Jackson for posting his code. That has got me the closest I've ever been to getting my flash contact form working.

If you don't mind could you show me how to add fields to the script. I have 5 inputs on my form. Name, email, phone, subject, and message. The Name and email show up in the headers and the message shows up in the message body with your script. Although I can't seem to ge the other information to show up.

Thanks Again
Craig

Sorry Markoman for using your thread....

oatesj77
1-17-06, 06:06 PM
you have your text input for phone number set to phone right? then you just need to collect that variable in your php page;
add this

change the message line to this;
$message = $_POST["message"]."</br>Phone number:".$_POST["phone"];

this should add line break at the end of your message body then attache the copy "phone number:" followed by whatever number was put into the form.

try that out post back if it doesn't work

clock109
1-17-06, 09:44 PM
Thanks again Jackson, That got me the information in the message body, but it all showed up on one line. Here's what it lookes like in the message body. I got a little brave and decided to try and add all the form information. :)

Name: Craig Lockett</br>Email Address:myemail@your.net</br>Phone number:123-4567</br>Subject:test this</br>Message:testing once more

oatesj77
1-19-06, 12:52 AM
that should have been <br/> or just <br>, my bad. that should give you the line returns if your email accepts html coding.

clock109
1-19-06, 04:20 PM
Thanks Jackson, but that didn't work for me either. I did get it working though my combining parts of another script with yours. I don't really understand php so I'm not sure why it worked. I just got lucky:) . Here's the final working script in case your interested in checking it out.

Thanks again for all your help. I couldn't have done it without you.....

<?php
$sendTo = "myemail@your.net";
$subject = $_POST ["subject"];
$name = $_POST["name"];
$email = $_POST["email"];
$phone = $_POST["phone"];
$subject = $_POST["subject"];
$message = $_POST["message"];

$headers = "From: " . $_POST["name"];
$headers .= "<" . $_POST["email"] . ">\r\n";
$headers .= "Reply-To: " . $_POST["email"] . "\r\n";
$headers .= "Return-Path: " . $_POST["email"];
$message = "Name:"."$name\n\n"."Email Address:"."$email\n\n"."Phone number:"."$phone\n\n"."Subject:"."$subject\n\n"."Message:\n"."$message";

mail($sendTo, $subject, $message, $headers);
?>

oatesj77
1-19-06, 08:14 PM
yeah, that'll work, you are just combining your variables into one ($message) and then using the mail functio like previously.