1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

PHP Mail form problems

Discussion in 'PHP' started by jasonleexxx, Jan 22, 2005.

  1. #1
    In my form I am getting the headings but not the information being entered.

    Here is the resulting email I get:
    occasion:
    partymonth:
    partyday:
    partytime:
    partyaddress:
    partystate:
    partyzip:
    partycrossstreets:
    partyphone:
    dancer:
    showlength:
    costume:
    masseuse:
    deposit:
    name:
    billingaddress:
    billingcity:
    billingstate:
    billingzip:
    contacttelephone:
    email:
    referredby:
    commentsquestion:
     
    jasonleexxx, Jan 22, 2005 IP
  2. jasonleexxx

    jasonleexxx Guest

    Messages:
    105
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <?php
    // get posted data into local variables
    $EmailTo = "el@662mob.com";
    $occasion = Trim($_POST['occasion']);
    $partymonth = Trim($_POST[partymonth]);
    $partyday = Trim($_POST[partyday]);
    $partytime = Trim($_POST[partytime]);
    $partyaddress = Trim($_POST[partyaddress]);
    $partystate = Trim($_POST[partystate]);
    $partyzip = Trim($_POST[partyzip]);
    $partycrossstreets = Trim($_POST[partycrossstreets]);
    $partyphone = Trim($_POST[partyphone]);
    $dancer = Trim($_POST[dancer]);
    $showlength = Trim($_POST[showlength]);
    $costume = Trim($_POST[costume]);
    $masseuse = Trim($_POST[masseuse]);
    $deposit = Trim($_POST[deposit]);
    $name = Trim($_POST[name]);
    $billingaddress = Trim($_POST[billingaddress]);
    $billingcity = Trim($_POST[billingcity]);
    $billingstate = Trim($_POST[billingstate]);
    $billingzip = Trim($_POST[billingzip]);
    $contacttelephone = Trim($_POST['contacttelephone']);
    $email = Trim($_POST[e-mail]);
    $referredby = Trim($_POST[referredby]);
    $commentsquestion = Trim($_POST[commentsquestion]);


    // prepare email body text
    $Body = "";
    $Body .= "occasion: ";
    $Body .= "$occasion";
    $Body .= "\n";
    $Body .= "partymonth: ";
    $Body .= "$partymonth";
    $Body .= "\n";
    $Body .= "partyday: ";
    $Body .= "$partyday";
    $Body .= "\n";
    $Body .= "partytime: ";
    $Body .= "$partytime";
    $Body .= "\n";
    $Body .= "partyaddress: ";
    $Body .= "$partyaddress";
    $Body .= "\n";
    $Body .= "partystate: ";
    $Body .= "$partystate";
    $Body .= "\n";
    $Body .= "partyzip: ";
    $Body .= "$partyzip";
    $Body .= "\n";
    $Body .= "partycrossstreets: ";
    $Body .= "$partycrossstreets";
    $Body .= "\n";
    $Body .= "partyphone: ";
    $Body .= "$partyphone";
    $Body .= "\n";
    $Body .= "dancer: ";
    $Body .= "$dancer";
    $Body .= "\n";
    $Body .= "showlength: ";
    $Body .= "$showlength";
    $Body .= "\n";
    $Body .= "costume: ";
    $Body .= "$costume";
    $Body .= "\n";
    $Body .= "masseuse: ";
    $Body .= "$masseuse";
    $Body .= "\n";
    $Body .= "deposit: ";
    $Body .= "$deposit";
    $Body .= "\n";
    $Body .= "name: ";
    $Body .= "$name";
    $Body .= "\n";
    $Body .= "billingaddress: ";
    $Body .= "$billingaddress";
    $Body .= "\n";
    $Body .= "billingcity: ";
    $Body .= "$billingcity";
    $Body .= "\n";
    $Body .= "billingstate: ";
    $Body .= "$billingstate";
    $Body .= "\n";
    $Body .= "billingzip: ";
    $Body .= "$billingzip";
    $Body .= "\n";
    $Body .= "contacttelephone: ";
    $Body .= "$contacttelephone";
    $Body .= "\n";
    $Body .= "email: ";
    $Body .= "$email";
    $Body .= "\n";
    $Body .= "referredby: ";
    $Body .= "$referredby";
    $Body .= "\n";
    $Body .= "commentsquestion: ";
    $Body .= "$commentsquestion";
    $Body .= "\n";

    // send email
    $success = mail($EmailTo, "booking", $Body);

    // redirect to success page
    if ($success){
    print "<meta http-equiv=\"refresh\" content=\"0;URL=home.htm\">";
    }
    else{
    print "<meta http-equiv=\"refresh\" content=\"0;URL=careers.htm\">";
    }
    ?>
     
    jasonleexxx, Jan 22, 2005 IP
  3. cgo85

    cgo85 Peon

    Messages:
    380
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    This should work try this:

    <?php
    //php form
    if (!isset($_POST['Submit'])) {
    include('page1.htm');
    }

    if (isset($_POST['Submit'])) {
    $occasion = $_POST['occasion'];
    $partymonth = $_POST['partymonth'];
    $partyday = $_POST['partyday'];
    $partytime = $_POST['partytime'];
    $msg = "Occasion: $occasion\n" .
    "Party Month: $partymonth\n".
    "Party Day: $partyday\n".
    "Party Time: $partytime\n";

    if ((!$occasion) || (!$partymonth) || (!$partyday) || (!$partytime))//this will require fields, else give error message
    {
    $error = "<strong><ul class=\"style21\">\n";
    if (!$occasion) { $error .= "<strong><li>Please enter your OCCASION</li></strong>"; }
    if (!$partymonth) { $error .= "<li>Please enter your PARTY MONTH</li>"; }
    if (!$partyday) { $error .= "<li>Please enter your PARTY DAY</li>"; }
    if (!$partytime) { $error .= "<li>Please enter your PARTY TIME</li>"; }
    include('page1.htm');
    exit;
    }
    mail("el@662mob.com","Booking",$msg,"From: $name <$email>");//mail it
    include('home.htm');//include page to go after successful form completion
    }
    ?>


    This is just a snippet... you will have to finish it following the above structure.
     
    cgo85, Jan 23, 2005 IP
  4. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #4
    it looks as if your variables do not contain values. are you sure that the values are being passed in correctly?

    e.g. you have:
    $occasion = Trim($_POST['occasion']);

    i suspect $occasion is still empty at this point...
     
    daboss, Jan 23, 2005 IP
  5. cgo85

    cgo85 Peon

    Messages:
    380
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #5
    works for me on my forms.
     
    cgo85, Jan 23, 2005 IP
  6. Eadz

    Eadz Peon

    Messages:
    108
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #6
    You are probally getting people just clicking submit without entering anything.

    If you do field validation this won't happen.
     
    Eadz, Jan 25, 2005 IP