SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: mail() question

  1. #1
    SitePoint Member
    Join Date
    Jan 2004
    Location
    indiana
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mail() question

    My first php interface. I have already checked with my ISP and they have said they cannot help. Below is code I found in another post on this forum. The form information is passed okay except for the mail header and I never receive an e-mail message. The actual form is at www.vincemay.com/dvd.htm which passes to www.vincemay.com/sendorder.php for processing. I ran the phpinfo() command, the results of which you will see if you click the sendorder.php link above.

    Thanks for any suggestions.
    Kathy

    <?php
    $name = $_POST['strName'];
    $company = $_POST['strCompany'];
    $email = $_POST['strEmail'];
    $phone = $_POST['strPhone'];
    $phoneext = $_POST['strPhoneExt'];
    $payment = $_POST['optPayment'];
    $shipping1 = $_POST['strShipAdd1'];
    $shipping2 = $_POST['strShipAdd2'];
    $shippingcity = $_POST['strShipCity'];
    $shippingstate = $_POST['lstShipState'];
    $shippingzip= $_POST['strShipZip'];
    $billing1 = $_POST['strBillAdd1'];
    $billing2 = $_POST['strBillAdd2'];
    $billingcity = $_POST['strBillCity'];
    $billingstate = $_POST['lstBillState'];
    $billingzip= $_POST['strBillZip'];
    $comments= $_POST['memComments'];

    $toaddress = "me@company.com";
    $subject = "DVD Order";

    $all= "Name: ".$name."\r\n\r\n";
    $all .= "Company: ".$company."\r\n\r\n";
    $all .= "E-Mail: ".$email."\r\n";
    $all .="Phone: ".$phone."\r\n";
    $all .="Phone Ext: ".$phoneext."\r\n";
    $all .="Payment Option: ".$payment."\r\n";
    $all .="Shipping Address, Line 1: ".$shipping1."\r\n";
    $all .="Shipping Address, Line 2: ".$shipping2."\r\n";
    $all .="Shipping City: ".$shippingcity."\r\n";
    $all .="Shipping State: ".$shippingstate."\r\n";
    $all .="Shipping Zip: ".$shippingzip."\r\n";
    $all .="Billing Address Line 1: ".$billing1."\r\n";
    $all .="Billing Address Line 1: ".$billing2."\r\n";
    $all .="Billing City: ".$billingcity."\r\n";
    $all .="Billing State: ".$billingstate."\r\n";
    $all .="Billing Zip: ".$billingzip."\r\n";
    $all .="Comments: ".$comments."\r\n";

    $mailheaders = "Content-type: text/plain; charset=iso-8859-1\r\n";
    $mailheaders .= "From: $email <$email>\r\n";
    mail($toaddress, $subject, $all, $mailheaders);
    ?>
    Last edited by kjmay; Dec 3, 2004 at 08:04.

  2. #2
    SitePoint Zealot
    Join Date
    Nov 2004
    Location
    Ankara/Turkey
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why dont you control the datas with regex (ereg, preg_match) it is more suitable for these type of things. okay here is an example someone write the billing zip and he writes: rtauhu (in turkey our zip codes are only numbers ex: 06500) do you like it??

  3. #3
    SitePoint Member
    Join Date
    Jan 2004
    Location
    indiana
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cappytoia,
    Thanks for your suggestion. I'm writing the code now for validating the form data in javascript on the form itself; the code I posted is on the php processor page that generates an e-mail message. If your next question is "why?" it's because this site is hosted by an ISP that only allows php server script, I don't know php, and, of course, it's a rush project.

  4. #4
    SitePoint Zealot
    Join Date
    Nov 2004
    Location
    Ankara/Turkey
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    but also remember that;
    javascript is not a good solution, a person who wants to harm your form may be does things below:

    he download form page and remove javascript and send, and also send, send, and send... and we Turkish says "Where is rush evil is there!"

  5. #5
    SitePoint Member
    Join Date
    Jan 2004
    Location
    indiana
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Working now

    I went from:

    $mailheaders = "Content-type: text/plain; charset=iso-8859-1\r\n";
    $mailheaders .= "From: $email <$email>\r\n";
    mail($toaddress, $subject, $all, $mailheaders);

    to:

    mail($toaddress, "DVD Order", $all, "FROM: me@mycompany.com");

    and it's working.

    cappytoi: thanks for the clarification; I did not know that was possible with JavaScript in forms. I'll take your advice on the next revision.


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
  •