Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post

    PHP/Flash guidance, please

    Hello

    I have many questions to ask about PHP, but one thing at a time.

    On a Windows server I have a Flash 'contact form' with the following (input text) fields: fullname, email, subject, country, message. I have given them the following 'Instance' names: name_txt, email_txt, subject_txt, country_txt, and message_txt.

    I have also given them the following variable names: fullname, email, subject, country, message.

    I have a script which my Flash file CAN communicate with. I know this because when I complete the Flash contact form I receive a message in my inbox.

    However, in the email I cannot see what the site visitor has input into the 'contact form' fields, meaning that PHP is not extracting information from them.

    This is the script I have at the moment:

    <?php

    //create short variable names
    $name=$_POST['name'];
    $email=$_POST['email'];
    $subject=$_POST['subject'];
    $country=$_POST['country'];
    $message=$_POST['message'];
    $name=trim($name);
    $email=trim($email);
    $subject=StripSlashes($subject);
    $country=StripSlashes($country);
    $message=StripSlashes($message);

    /*#########
    modify the next line with your own email address
    ###########*/

    $toaddress='myEmail@wherever.com';


    if (preg_match ("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn |bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk| dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs |gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr| kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum |mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr |pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf |tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za| zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i", $email)) {
    mail($toaddress,$subject,$country,$message,"From: $name <$email>\r\nReply-To: $email\r\nReturn-Path: $email\r\nCc: $email\r\n");
    //clear the variables
    $name='';
    $email='';
    $subject='';
    $country='';
    $message='';
    echo "response=passed";
    } else {
    echo "response=invalid";
    exit;
    }

    ?>

    What I would like to ask is do I need to replace:

    $name=$_POST['name'];
    $email=$_POST['email'];
    $subject=$_POST['subject'];
    $country=$_POST['country'];
    $message=$_POST['message'];


    with this:


    $_REQUEST['fullname'];
    $_REQUEST['email'];
    $_REQUEST['subject'];
    $_REQUEST['country'];
    $_REQUEST['message'];

    And finally, where do I begin to remove/end the email validity check in the above script? My own Action Script in Flash does this, so I do not need it here.

    Many thanks.

    Steve

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    $_REQUEST[' ']; is not recommended because it opens to all or any incoming data.

    I would try $_GET first (assuming $_POST does not work).

    As a last resort, try $_REQUEST

    =================

    Your error checking problem? ....

    Take this part:
    if (preg_match ("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn |bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk| dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs |gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr| kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum |mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr |pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf |tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za| zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i", $email)) {
    mail($toaddress,$subject,$country,$message,"From: $name <$email>\r\nReply-To: $email\r\nReturn-Path: $email\r\nCc: $email\r\n");
    //clear the variables
    $name='';
    $email='';
    $subject='';
    $country='';
    $message='';
    echo "response=passed";
    } else {
    echo "response=invalid";
    exit;
    }


    And make it this ...

    mail($toaddress,$subject,$country,$message,"From: $name <$email>\r\nReply-To: $email\r\nReturn-Path: $email\r\nCc: $email\r\n");
    //clear the variables
    $name='';
    $email='';
    $subject='';
    $country='';
    $message='';
    exit;


    You have some other issues too ...

    Like, don't let them enter the subject, do that yourself.
    Put their subject with the message instead.
    Don't let them enter who the email goes to ... only
    who the email is from.

    Hard-code the subject, and the "to" address.


    .
    Last edited by mlseim; 12-30-2007 at 12:51 AM.

  • #3
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    Hello mlseim

    Many thanks for your informative post.

    I do actually have my own 'to' address (as oposed to the 'from' address) here:

    $toaddress='myEmail@wherever.com';

    but I will remove it since it looks better the way you have it, that is:

    mail($toaddress,$subject,$country,$message

    In order to include a CC or BCC, would I include (in the above line, that is: mail($toaddress,$subject, etc etc etc), the following (as, at some stage, I will attempt to have the email HTML formatted):

    $headers .= "\r\nCc: he@$hisdomain.com";
    $headers .= "\r\nBcc: her@$herdomain\r\n\r\n";

    Many thanks again mlseim and all the best for 2008!

    Steve

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Included just like they have in their example I think ...

    mail($toaddress,$subject,$country,$message,"From: $name <$email>\r\nReply-To: $email\r\nReturn-Path: $email\r\nCc: $email\r\n");

    $header would be the part within quotes.

    For HTML email, use Google to search for: PHP HTML email

    There are some mime type things that need to be done.

  • #5
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    Many thanks again mlseim. Grateful for your help.

    Cheers

    Steve

  • #6
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    Also, please visit this link.
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #7
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Also know that we didn't even get into the part about
    spammers and forms ... you'll have to cross that bridge
    when you get there.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •