A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: Mail form php , did a few tut. anyone got a simple way to just make a php mail form ?

  1. #1
    Senior Member
    Join Date
    Aug 2004
    Posts
    102

    Mail form php , did a few tut. anyone got a simple way to just make a php mail form ?

    anyone got any simple tutorial that goes thru how to make a php ...mail form... ?

    also wanted to get some feed back on my new site and which one you guys like better

    www.vpactive.com
    new one > www.vpactive.com/vpnewwebsite.html

    aight THIZANKS

  2. #2
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    code:

    on(press) {
    getURL("mailto:somebody@somewhere.com");
    }


  3. #3
    Registered User
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    you seem to know the flash side, so here is some php

    Code:
    <?
    $name = $_POST["name"];
    $email = $_POST["email"];
    $message = str_replace("\r", "\n", $_POST["message"]);
    mail("you@yoursite.com", "Contact form", "Contact form filled by
    Name: $name
    Email: $email
    Message: $message
    ", "From: webserver@yoursite.com");
    ?>
    Musicman

  4. #4
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    1. open notepad. paste this
    Code:
    <?php
    $a= $_POST['a0'];
    $s = $_POST['a1'];
    $m = $_POST['a2'];
    mail($a,$s,$m);
    ?>
    2. save it as mail.php.

    3. open a new fla. paste this
    code:
    l = new LoadVars();
    r = new Array("address:", "subject:", "message:");
    for (var i = 0; i<r.length; i++) {
    l.a[i] = "";
    this.createTextField("tf"+i, i, 0, 40*i, 400, 22);
    this["tf"+i].text = r[i];
    this["tf"+i].border = true;
    this["tf"+i].type = "input";
    this["tf"+i].q = i;
    this["tf"+i].onChanged = function() {
    l["a"+this.q] = this.text;
    };
    }
    k = new Object();
    Key.addListener(k);
    k.onKeyDown = function() {
    if (Key.isDown(Key.ENTER)) {
    l.sendAndLoad("mail.php", l, "POST");
    }
    };


    (untested)
    4. save and publish.
    5. copy both the swf and the mail.php and copy them to your server. both files need to be in the same directory.
    6. you have to chmod the mail.php form to all executable. if you're using IE's ftp, just right-click it and check all the boxes on the far right (there are 3 rows of 3 boxes each).

    that's pretty much it, but php requires a program to work. chances are you don't have this programming running, although i could be wrong. that means if you test this on your local machine, it wont send a mail, but should be fine when hosted on your server.

  5. #5
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    just tested, and it actually works. i'm stunned.

  6. #6
    Registered User
    Join Date
    Feb 2001
    Posts
    13,044
    Hi moagrius,

    never let the flash form specify the destination address unless you really need (and then take some precautions against abuse)
    You have just created a means for some idiot to send a few thousand "cheap viagra" mails with your server as sender

    Musicman

  7. #7
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    hi musicman,

    barring hardcoding the recipients address, what alternatives are there if you want a mailform allowing arbitrary addressees?

  8. #8
    Registered User
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    maybe some dialogue between the movie and the server, to ensure that the request indeed comes from a flash form, rather than a submission script.
    I could also imagine that using flash remoting instead of loadvars would help a bit - spammers likely would go and look for an easier target

    Musicman
    Last edited by Musicman; 12-04-2004 at 05:06 PM.

  9. #9
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    i cant disagree that security is always a good idea, but with an average spammail weighing in at somewhere around 3-4kb, and bandwidth going for a gig a penny, i'd have to say it's not something i'd consider worth the worry

  10. #10
    Registered User
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    bandwidth is not the only issue....

    a) you probably do not want certain types of spam sent with YOUR domain as the sender
    b) sending spam is likely to cause mail blocking - if you are on a shared server together with some 20 other domains, a notable part of the internet might refuse to accept mails from these 20 domains as well (or even from all domains hosted by the same hosting company)
    You are likely to get some nasty letters from affected people

    Just as an example, I get internet access and email from a big provider. It occasionally happens that one of their clients gets infected with some mail-sender pests. As a consequence another big provider (rr.com - which incidentally is known throughout the world as a source of spam) decided to block all mails from that network.
    Staying in touch with people was an unpleasant and time-comsuming experience - and I really would not want to resort to international phone calls

    Musicman

  11. #11
    Senior Member
    Join Date
    Aug 2004
    Posts
    102
    I got the code and the php stuff...

    but how do i create the content in the flash to support the php

    i don't know how to code the little dynamic text boxes.

    like for the first box i just want name
    user to put in name

    second will be the comments section.

    so basically creating the dynamic text boxes...allowing the user to put in the info...to be sent via email to me on submission.

    ( so basically how do i script the dynamic text boxes in flash to work with the php)
    -------------------------------------------------------------------

    1. open notepad. paste this
    code:<?php$a= $_POST['a0'];$s = $_POST['a1'];$m = $_POST['a2'];mail($a,$s,$m);?>

    2. save it as mail.php.

    3. open a new fla. paste this
    ActionScript:{l = new LoadVars();
    r = new Array("address:", "subject:", "message:");
    for (var i = 0; i<r.length; i++) {
    l.a[i] = "";
    this.createTextField("tf"+i, i, 0, 40*i, 400, 22);
    this["tf"+i].text = r[i];
    this["tf"+i].border = true;
    this["tf"+i].type = "input";
    this["tf"+i].q = i;
    this["tf"+i].onChanged = function() {
    l["a"+this.q] = this.text;
    };
    }
    k = new Object();
    Key.addListener(k);
    k.onKeyDown = function() {
    if (Key.isDown(Key.ENTER)) {
    l.sendAndLoad("mail.php", l, "POST");
    }
    };



    (untested)
    4. save and publish.
    5. copy both the swf and the mail.php and copy them to your server. both files need to be in the same directory.
    6. you have to chmod the mail.php form to all executable. if you're using IE's ftp, just right-click it and check all the boxes on the far right (there are 3 rows of 3 boxes each).

    that's pretty much it, but php requires a program to work. chances are you don't have this programming running, although i could be wrong. that means if you test this on your local machine, it wont send a mail, but should be fine when hosted on your server.



    ***** and isn't there a piece of info missing about a button ????? Aren't i supposed to attach some actionscript to a button and make one ?
    k.onKeyDown = function() {
    if (Key.isDown(Key.ENTER)) {
    l.sendAndLoad("mail.php", l, "POST");
    }
    };
    //IS ENTER A INSTANCE NAME OF THE BUTTON ???// OR THE ENTER KEY ON THE KEYBOARD ?

    IVE HEARD ALL OF YOU GUYS COMMENTS GOOD AND BAD., HOW IS THE BEST WAY TO DO THIS ??

  12. #12
    Senior Member
    Join Date
    Aug 2004
    Posts
    102
    <?
    $name = $_POST["name"];
    $email = $_POST["email"];
    $message = str_replace("\r", "\n", $_POST["message"]);
    mail("you@yoursite.com", "Contact form", "Contact form filled by
    Name: $name
    Email: $email
    Message: $message
    ", "From: webserver@yoursite.com");
    ?>


    * THIS CODE SEEMS NICE AND PRETTY SIMPLE.

    BUT HOW DO I CREATE THE DYNAMIC TEXT BOXES THAT THE USER CAN PUT THE INFO (DATA ENTRY) INTO , IN FLASH ??//

    // I GOT THE PHP CODE, NOW BASICALLY HOW DO I DO THE FLASH PART AND PUT IN THE TEXT AREAS ?

  13. #13
    Registered User
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    here is some simple code
    Code:
    on (release) {
            mylv = new LoadVars();
            mylv.name = name.text;
            mylv.email = email.text;
            mylv.message = message.text;
            myreply = new LoadVars();
            mylv.sendAndLoad('mail.php', myreply, 'POST');
    }
    You may want to add later
    - check that fields are not empty
    - check that email looks like email (has @ in the middle and at least one period to the right)
    - display a message that mail was sent or could not be sent

    Musicman
    Attached Files Attached Files

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