Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Supporting Technologies > Server-Side Scripting

Reply
 
Thread Tools Rating: Thread Rating: 32 votes, 5.00 average. Display Modes
Old 05-09-2004, 12:47 PM   #1
free mojo
Registered User
 
Join Date: Oct 2003
Posts: 236
Default PHP - form (email contact form)

This is very similar to the other post. I have made a contact form. The information is in a MC called form. On the first keyframe it has this code:
PHP Code:
stop();
// this function empties the text boxes once
// the mail has been sent - you could just as easily use it
// to remove or hide an mc or whatever you want
function emptyTxtBoxes2() {
    
name.text "";
    
email.text "";
    
text.text "";
}
// check boxes function
function checkBoxes2() {
    if (!
name.text.length) {
        
gotoAndStop("feedback");
        
theresponse.text "Please type in your name";
    } else if (!
email.length || email.indexOf("@") == -|| email.indexOf(".") == -1) {
        
gotoAndStop("feedback");
        
theresponse.text "Please type a valid email address";
    } else if (!
text.text.length) {
        
gotoAndStop("feedback");
        
theresponse.text "Please type your message";
    } else {
        
sendmail2();
    }
}
// newLoadvars - convert txtx boxes to variables
function sendmail2() {
    
myLVs = new LoadVars();
    
myLVs.name name.text;
    
myLVs.email email.text;
    
myLVs.message text.text;
    
myLVs.onLoad = function(success) {
        if (
success) {
            
// clear text boxes
            
emptyTxtBoxes2();
            
// tell user mail has been sent
            
gotoAndStop("feedback");
            
theresponse.text this.response;
        }
    };
    
myLVs.sendAndLoad("mailform.php"myLVs"POST");
}
send_form.onRelease = function() {
    
checkBoxes2();
}; 
the php file has a parse error on line 15, but the code is very similar to the mailing list one and that is error free, but the email doesn't send.
The problem with this is that the email doesn't send and there is NO response at all. I am a php beginner so sorry i can't see the error. I really need to sort out this though.
This is the php code:
PHP Code:
<?php 
//collect vars from flash 
$name $_POST['name']; 
$email $_POST['email']; 
$message $_POST['message']; 

/*add anyother variables that you 
want displayed in the email*/ 

$ToSubject "message from my site"
$ToM "[email protected]"
$sendTo  =  "freemojo"
$myMessage "$name has sent you an email from your site with this message:\n\n$message\n\nReply to: $email"

mail($sendTo "<".$ToM.">",$ToSubject,$myMessage,"From:".$name."<".$email.">"); 
/*response to sender*/
$response "Thanks for your message $name";

/*echo response to flash*/
echo '&response='.urlencode($response);

?>
Please help if you can. Thanks alot. Also have a look at the other post too, i'm really in need of the help!

Last edited by CyanBlue; 05-09-2004 at 12:51 PM. Reason: PHP tag is applied...
free mojo is offline   Reply With Quote
Old 05-09-2004, 12:56 PM   #2
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Howdy...

At a first glance, the first argument that you have in the mail() function is the one that's causing the problem...

Get rid of the $sendTo and the brackets and see if that works...
PHP Code:
mail($ToM$ToSubject$myMessage"From:".$name."<".$email.">"); 
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 05-10-2004, 05:32 AM   #3
free mojo
Registered User
 
Join Date: Oct 2003
Posts: 236
Default

Thanks CyanBlue, I've done that and that makes the php file clean, i've tested it. But the email or response aren't working. Then i realised it's something to do with the response being named repsonse in php and "theresponse" is the text field in flash. I've changed it but haven't been able to test it on a server yet. Does that sound like a reason why it wouldn't work though?

And also like the other post, the email validation won't work well. (see the other post for more details)

Thanks for your help. anyone?
Please someone have a look at my guestbook post i really can't sort that out.
free mojo is offline   Reply With Quote
Old 05-10-2004, 07:55 AM   #4
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Well... Why don't you post your sample if it is not working???

As for the email validation... Check these prototypes...

http://proto.layer51.com/d.aspx?f=78
http://proto.layer51.com/d.aspx?f=188
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 05-10-2004, 09:55 AM   #5
free mojo
Registered User
 
Join Date: Oct 2003
Posts: 236
Default

I don't know how to implement those protos.
free mojo is offline   Reply With Quote
Old 05-10-2004, 01:34 PM   #6
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Um... The example of using the first prototype will be...
PHP Code:
str "what.is@wrong";
trace(str.isEmail()); 
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 05-11-2004, 01:06 PM   #7
walterppk
Member
 
Join Date: May 2004
Posts: 63
Default PHP email validator

assuming your the email address is held in a variable called email you can have PHP validate to and return a response.

<?
...

if(!(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+[a-z]{2}[mtgvu]?$", $email))) return 0;
else return 1

...
?>
walterppk is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:11 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.