SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Sep 2007
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question problem with my php form

    Hi guys

    Im no php programmer im just starting out,

    i have a html form where the action is sent to a php file

    in the form are the usual email, name, tel, a check box and some radio buttons. below is my php code and it works fine but im tying to get all the information in to the message it only seems to send 1 item..

    im not really sure where to add this information in a logical manner

    <?
    $email = $_REQUEST['email'] ;
    $message = $_REQUEST['message'] ;
    $name = $_REQUEST['name'] ;



    mail( "myemail@help.com", "Feedback Form Results",$message, "From: $email" );



    header( "Location: http://www.help.com/test php/thankyou.htm" );
    ?>



  2. #2
    SitePoint Addict
    Join Date
    Aug 2005
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just extend the $message variable to include what you want included

    PHP Code:
    $message  "From: " $_POST['name'] . "\r\n";
    $message .= "Phone: " $_POST['phone'] . "\r\n";
    $message .= "Zip Code: " $_POST['zip_code'] . "\r\n\r\n";
    $message .= "Message...\r\n\r\n";
    $message .= $_POST['message'] . "\r\n"
    But a word of warning, if your going to allow the use of the extra parameter in the mail() function, then you need to validate the incoming input because anyone can inject a special crafted string that will allow them to use your script to send mail to others. Which could create problems for you.

  3. #3
    SitePoint Member
    Join Date
    Sep 2007
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    I didnt use it exactly but its worked perfectly!!! thanks. if I was to add text that would appear before each message where would I put that.

    and if I was to put some validation on this php it would be to the message variables Im guessing..

    thanks for your help

  4. #4
    SitePoint Wizard Hammer65's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln Nebraska
    Posts
    1,161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The extra text would be the first thing you add to the $message variable.

    Google for "PHP mail injection" to get an idea of what is required to prevent an attack like that. That won't entirely prevent form spamming, but at least they won't be able to send to any but the genuine recipient of the mail.

    Complete protection involves captcha images, spam filtering, IP blocking and various other measures


Bookmarks

Posting Permissions

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