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 10 of 10
  1. #1
    New Coder
    Join Date
    Mar 2010
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Dropdowns not sending in email forms php

    Hi everyone,

    I need help, I cant figure out why my email form is not sending the dropdown menu information in the email. Everything else thats not a dropdown works fine and even validates, but not the dropdow options. Can someone help me.
    Below is the html page
    [CODE]
    <td width="596" class="pageName">Fill Out Our Form To Schedule An Appointment</td>
    </tr>
    <tr>
    <td class="bodyText">
    <form method="post" enctype="multipart/form-data" action="contact.php" accept-charset="utf-8">
    <table border="0" cellpadding="0" cellspacing="0" align="center">
    <tr>
    <td><h3 style="border-bottom:1px solid black;">Schedule An Appointment</h3></td>
    </tr>
    <tr>
    <td>
    <label for="First" style="float:left;width:140px;">First Name*</label><input type="text" name="First" id="First" maxlength="" style="width:100px;"><div style="clear:left;height:20px;"> </div>

    <label for="Last" style="float:left;width:140px;">Last Name*</label><input type="text" name="Last" id="Last" maxlength="" style="width:200px;"><div style="clear:left;height:20px;"> </div>

    <label for="Street" style="float:left;width:140px;">Street Address*</label><input type="text" name="Street" id="Street" maxlength="" style="width:200px;"><div style="clear:left;height:20px;"> </div>

    <label for="Address2" style="float:left;width:140px;">Address 2</label><input type="text" name="Address2" id="Address2" maxlength="" style="width:200px;"><div style="clear:left;height:20px;"> </div>

    <label for="City" style="float:left;width:140px;">City*</label><input type="text" name="City" id="City" maxlength="" style="width:100px;"><div style="clear:left;height:20px;"> </div>

    <label for="Zip" style="float:left;width:140px;">Zip*</label><input type="text" name="Zip" id="Zip" maxlength="" style="width:100px;"><div style="clear:left;height:20px;"> </div>

    <label for="email" style="float:left;width:140px;">E-Mail Address*</label><input type="text" name="email" id="email" maxlength="" style="width:200px;"><div style="clear:left;height:20px;"> </div>

    <label for="EmailConf" style="float:left;width:140px;">Confirm E-Mail Address*</label><input type="text" name="EmailConf" id="EmailConf" maxlength="" style="width:200px;"><div style="clear:left;height:20px;"> </div>

    <label for="Phone" style="float:left;width:140px;">Best Contact Phone* Number</label><input type="text" name="Phone" id="Phone" maxlength="" style="width:200px;"><div style="clear:left;height:20px;"> </div>

    <label style="float:left;width:140px;" for="AppointType">I would Like An Appointment For:*</label><select name="AppointType" id="AppointType">
    <option value="Estimate">New Unit Estimate</option>
    <option value="Diagnostic">Diagnostic</option>
    <option value="A/C Service">A/C Service</option>
    <option value="Heater Service">Heater Service</option>
    <option value="Warranty">Warranty</option>
    <option value="Service Agreement Schedule">Yearly Maintenance</option>
    </select><div style="clear:left;height:20px;"> </div>

    <label style="float:left;width:140px;" for="Time">My Requested Appointment Time</label><select name="Time" id="Time">
    <option value="Morning">Morning</option>
    <option value="Noonish">Noonish</option>
    <option value="Mid Afternoon">Mid Afternoon</option>
    <option value="Evening">Evening</option>
    </select>
    <div style="clear:left;height:20px;"> </div>

    <label style="float:left;width:140px;" for="Day[]">The Day I request for Service Is: <br />
    ( Hold Shift + Click For Multiple Selections)</label><select name="Day[]" multiple="MULTIPLE" id="Day[]">
    <option value="Monday">Monday</option>
    <option value="Tuesday">Tuesday</option>
    <option value="Wednesday">Wednesday</option>
    <option value="Thursday">Thursday</option>
    <option value="Friday">Friday</option>
    <option value="This week">This Week</option>
    <option value="Next Week">Next Week</option>
    <option value="Any Available Day" selected="selected">Any Available Appointment</option>
    </select>
    <div style="clear:left;height:20px;"> </div>

    <label style="float:left;width:140px;" for="System">My System is a :</label><select name="System" multiple="multiple" id="System">
    <option value="Package" selected="selected">Package Unit</option>
    <option value="Split System">Split System</option>
    <option value="Heat Pump">Heat Pump</option>
    <option value="Don't Know">Don't Know</option>
    <option value="N/A">Not Applicable</option>
    </select>
    <div style="clear:left;height:20px;"> </div>

    <label style="float:left;width:140px;" for="GasType">My Primary Type Of Gas is:</label>
    <select name="GasType" multiple="multiple" id="GasType">
    <option value="Natural Gas">Natural Gas</option>
    <option value="Propane">Propane</option>
    </select>
    <div style="clear:left;height:20px;"> </div>

    <label style="float:left;width:140px;" for="Age">I think The Age Of My System Is:</label><select name="Age" multiple="multiple" id="Age">
    <option value="1-2 YO" selected="selected">1-2 Years Old</option>
    <option value="3-6 YO">3-6 Years Old</option>
    <option value="7-10 YO">7-10 Years Old</option><option value="11-15 YO">11-15 Years Old</option><option value="16-20 YO">16-20 Years Old</option><option value="21+ YO">21 Years +</option>
    </select>
    <div style="clear:left;height:20px;"> </div>

    <label for="BrandName" style="float:left;width:140px;">The Brand Name I Have Or I'm Interested In Is:</label><input type="text" name="BrandName" id="BrandName" maxlength="200" style="width:300px;"><div style="clear:left;height:20px;"> </div>

    <label for="Comments" style="float:left;width:140px;">Additional Requests, Comments or Description*</label><textarea name="Comments" id="Comments" style="width:400px;height:250px;">Additional Comments</textarea><div style="clear:left;height:20px;"> </div>

    </td>
    <tr>
    <td align="right">
    <!-- YOU CAN MODIFY THE TEXT WITHIN VALUE="" TO MODIFY YOUR BUTTON TEXT-->
    <input type="submit" value=" Submit "> <input type="reset" value=" Reset ">
    </td>
    </tr>
    </table>
    </form> <p>&nbsp;</p>
    [CODE]

    ---------------------------------
    And the php code

    [CODE]
    <?php
    $AppointType= $_POST['AppointType'];
    $email = $_POST['email'];

    if(!$_POST) exit;

    //$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
    if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){
    $error.="Invalid email address entered";
    $errors=1;
    }
    if($errors==1) echo $error;
    else{
    $value = array ('First','Last','Street', 'Address2', 'City', 'Zip','email','EmailConf','Phone','AppointType','Time','Day[]','System','GasType', 'Age', 'BrandName', 'Comments');
    $required = array('First','Last','Street','City','Zip','email','Phone');

    $your_email = "$email";
    $email_subject = "New Customer Inquiry ";
    $email_content = "\n";
    $mailheader = "From: ".$_POST["email"]."\r\n";

    foreach($value as $key => $value){
    if(in_array($value,$required)){
    if ($key != 'email' && $key != 'First' && $key != 'Last' && $key != 'Street' && $key != 'City' && $key != 'Zip' && $key != 'Phone') {
    if( empty($_POST[$value]) ) { print ("ALL FIELDS ARE REQUIRED* Please press your back button<br>"); exit; }
    }
    $email_content .= $value.': '.$_POST[$value]."\n";

    }
    }

    if(mail("info@airspecialist.org",$email_subject, $email_content, "From: $email")) {
    print 'Your message has been sent! We will be contacting you shortly.';
    } else {
    echo 'ERROR!';
    }
    echo "<BR>";
    echo "<a href='index.html'>Return to our Home Page</a>";
    }
    ?>
    [CODE]

  • #2
    New Coder
    Join Date
    Mar 2010
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Please Anyone?? I'm trying to learn as I go, I'm not great at all this stuff, but I can get it if someone explains it to me... I really need your help. Please forgive me if I posted too much, this is my first time

  • #3
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Netscape

    It looks like the form is supposed to send multiple dropdown options if selected, right?

    I would use checkboxes instead for multiple items, because I think it would be easier in my opinion especially since it is using an array.

  • #4
    New Coder
    Join Date
    Mar 2010
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Yeah, that seems like a great idea, but how do I get the information to be included in the email?? When I receive the email, it does not include any of the selection item at all, it doesnt even list them, what am I doing wrong?

  • #5
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    This is your PHP code:
    PHP Code:
    <?php
    $AppointType
    $_POST['AppointType'];
    $email $_POST['email'];

    if(!
    $_POST) exit;

    //$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
    if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){
        
    $error.="Invalid email address entered";
        
    $errors=1;
    }
    if(
    $errors==1) echo $error;
    else{
        
    $value = array ('First','Last','Street''Address2''City''Zip','email','EmailConf','Phone','AppointType','Time','Day[]','System','GasType''Age''BrandName''Comments');
        
    $required = array('First','Last','Street','City','Zip','email','Phone');

        
    $your_email "$email";
        
    $email_subject "New Customer Inquiry ";
        
    $email_content "\n";
        
    $mailheader "From: ".$_POST["email"]."\r\n";

        foreach(
    $value as $key => $value){
            if(
    in_array($value,$required)){
                if (
    $key != 'email' && $key != 'First' && $key != 'Last' && $key != 'Street' && $key != 'City' && $key != 'Zip' && $key != 'Phone') {
                    if( empty(
    $_POST[$value]) ) {
                        print (
    "ALL FIELDS ARE REQUIRED* Please press your back button<br>");
                        exit;
                    }
                }
                
    $email_content .= $value.': '.$_POST[$value]."\n";

            }
        }

        if(
    mail("info@airspecialist.org",$email_subject$email_content"From: $email")) {
            print 
    'Your message has been sent! We will be contacting you shortly.'
        } else {
            echo 
    'ERROR!';
        }
        echo 
    "<BR>";
        echo 
    "<a href='index.html'>Return to our Home Page</a>";
    }
    ?>
    Now let's consider something:
    Code:
    if($errors==1) echo $error; 
    else{ 
        $value = array ('First','Last','Street', 'Address2', 'City', 'Zip','email','EmailConf','Phone','AppointType','Time','Day[]','System','GasType', 'Age', 'BrandName', 'Comments'); 
        $required = array('First','Last','Street','City','Zip','email','Phone'); 
    
        $your_email = "$email"; 
        $email_subject = "New Customer Inquiry "; 
        $email_content = "\n"; 
        $mailheader = "From: ".$_POST["email"]."\r\n"; 
    
        foreach($value as $key => $value){ 
    ...
        } 
    ...
    }
    You really should rename your variable for your list of labels to something OTHER THAN "$value".

    But really, right now you should write to a moderator and ask to have your post moved into the PHP forum (don't re-post there, have a mod actually move this thread). You will get more and better help by following the rules and posting in the correct category.
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • #6
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    This line is in the wrong place, I think.
    PHP Code:
    $email_content .= $value.': '.$_POST[$value]."\n"
    Looks like it's inside of the if(in_array($value,$required)) test for required fields, so it's only adding the required fields to the $email_content variable. Move it outside of that if statement's closing bracket.

    PHP Code:
        foreach($value as $key => $value)
        {
            if(
    in_array($value,$required))
            {
                if (
    $key != 'email' && $key != 'First' && $key != 'Last' && $key != 'Street' && $key != 'City' && $key != 'Zip' && $key != 'Phone'
                {
                    if( empty(
    $_POST[$value]) ) 
                    { 
                        print (
    "ALL FIELDS ARE REQUIRED* Please press your back button<br>"); 
                        exit; 
                    }
                }
                
    /* from here */
            
    }
            
    /* to here */
            
    $email_content .= $value.': '.$_POST[$value]."\n";
        } 
    Unrelated, but you may want to change the ID Day[] to Day in both the form and the form handler.
    Are you a Help Vampire?

  • Users who have thanked tomws for this post:

    happeemom (03-24-2010)

  • #7
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Quote Originally Posted by Rowsdower! View Post
    But really, right now you should write to a moderator and ask to have your post moved into the PHP forum (don't re-post there, have a mod actually move this thread). You will get more and better help by following the rules and posting in the correct category.
    They may be able to merge the threads, which would help.
    Are you a Help Vampire?

  • #8
    New Coder
    Join Date
    Mar 2010
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by tomws View Post
    This line is in the wrong place, I think.
    PHP Code:
    $email_content .= $value.': '.$_POST[$value]."\n"
    Looks like it's inside of the if(in_array($value,$required)) test for required fields, so it's only adding the required fields to the $email_content variable. Move it outside of that if statement's closing bracket.

    PHP Code:
        foreach($value as $key => $value)
        {
            if(
    in_array($value,$required))
            {
                if (
    $key != 'email' && $key != 'First' && $key != 'Last' && $key != 'Street' && $key != 'City' && $key != 'Zip' && $key != 'Phone'
                {
                    if( empty(
    $_POST[$value]) ) 
                    { 
                        print (
    "ALL FIELDS ARE REQUIRED* Please press your back button<br>"); 
                        exit; 
                    }
                }
                
    /* from here */
            
    }
            
    /* to here */
            
    $email_content .= $value.': '.$_POST[$value]."\n";
        } 
    YAHOOOOOOOOOOOOOOOOO!!!!! I could just kiss you!! Thank you, thank you, thank you!!!! I am super happy! How the heck did I miss that?? Those stupid brackets, lol! IT WORKED! tomws, you are the man! Thanks guys for your help..... I can finally sleep! I will mark this as solved and see if I can get a moderator to move it to php. Thank you all for your help.

  • #9
    New Coder
    Join Date
    Mar 2010
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    um... one more question.....how do I contact a moderator to get the thread moved?

  • #10
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Quote Originally Posted by happeemom View Post
    um... one more question.....how do I contact a moderator to get the thread moved?
    2 ways. 1) hit the flag link in the user box to the left, or 2) scroll to the bottom of the forum and pick a mod's name.
    Are you a Help Vampire?


  •  

    Posting Permissions

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