A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [RESOLVED] new to PHP. contact form question.

  1. #1
    Member
    Join Date
    Feb 2006
    Posts
    96

    resolved [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

  2. #2
    Senior Member
    Join Date
    Jul 2005
    Posts
    692
    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:
    PHP Code:
    ?PHP
    Should be:
    PHP Code:
    ?> 

  3. #3
    Member
    Join Date
    Feb 2006
    Posts
    96
    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

    }

    ?>

  4. #4
    Member
    Join Date
    Feb 2006
    Posts
    96
    I found a script that worked.

  5. #5
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center