|
-
[RESOLVED] new to PHP. contact form question.
I have a simple 3 field contact form written in AS3. I have verified it to the point where I send my data to PHP and it all works as intended.
However, because of my ignorance of PHP, I am lost when it comes to actually getting Flash and PHP to talk to 1 another. I have been working on this for a day and a 1/2 now and about to pull my hair out!
My flash collects and stores 3 variables (contactName, contactEmail, contactComments) and then passes them to PHP. I would then like PHP to send an email to a predetermined address and confirm the email was sent. Simple enough, right?
The code is pieced together from other examples from Flashkit and other sites.
here is my relevant AS3 code:
sidenote: PHP version is 5.2.2
PHP Code:
var contactVariables:URLVariables = new URLVariables();
var phpSend:URLRequest=new URLRequest('contact.php');
var phpLoader:URLLoader=new URLLoader();
phpSend.method=URLRequestMethod.POST;
phpSend.data=contactVariables;
function sendMail():void {
contactVariables.contactName=contactName;
contactVariables.contactEmail=contactEmail;
contactVariables.contactComments=contactComments;
phpLoader.load(phpSend)
}
PHP Code:
<?PHP
$to="[email protected]";
$subject="ABC Company Web Contact Form"
//pass variables
$name=$_POST['contactName'];
$email=$_POST['contactEmail'];
$comments=$_POST['contactComments'];
if(mail($to, $subject, $comments, "Sender: $name)){
print('&mail=1'); //success
} else {
print('&mail=0'); //failure
}
?PHP>
Last edited by compjock; 11-18-2009 at 03:56 PM.
Reason: insert PHP version
-
Well, you have a syntax error which could be part of your problem. I don't actually get what your problem is however.
PHP Code:
if(mail($to, $subject, $comments, "Sender: $name)){
Should be:
PHP Code:
if(mail($to, $subject, $comments, "Sender: $name")){
Also:
Should be:
-
thanks for the response. I've made the 2 corrections per your post. (simple mistake leaving out the close quotes - can't believe I did that.) However, mail is still not being sent.
That is my problem. It seems everything is right, but nothing is sent. Also, I don't know if i have my AS3 setup right to receive a response back from php the email was sent successfully or failed.
any help is much appreciated.
corrected PHP code.
PHP Code:
<?PHP
$to="[email protected]";
$subject="ABC Company Web Contact Form"
//pass variables
$name=$_POST['contactName'];
$email=$_POST['contactEmail'];
$comments=$_POST['contactComments'];
if(mail($to, $subject, $comments, "Sender: $name")){
print('&mail=1'); //success
} else {
print('&mail=0'); //failure
}
?>
-
I found a script that worked.
-
Hi,
just a comment on mail() - on unix-style webserver mail is considered successful if
- mailing from php has not been disabled by the admin
- there is no severe error in the server config and
- there is enough space on the server's hard disk to queue the mail for sending
So testing success of mail() is not really helpful
Musicman
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|