Results 1 to 3 of 3

Thread: chained select in php mailform

  1. #1
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    923
    Thanks
    121
    Thanked 2 Times in 2 Posts

    Default chained select in php mailform

    1) Script Title: Chained Select Menu

    2) Script URL (on DD): http://dynamicdrive.com/dynamicindex...menu/index.htm

    3) Describe problem:

    Hey all,

    As I am trying to get the selected into a mailform, here's what I did:

    Code:
    <select class="custom-select" type="text" name="firstlevel" id="firstlevel" required></select>
    <select class="custom-select" type="text" name="secondlevel" id="secondlevel" required></select>
    <select class="custom-select" type="text" name="thirdlevel" id="thirdlevel" required></select>
    And the php of the mail form:

    Code:
    <?php
    
    $ip = $_SERVER['REMOTE_ADDR']; // get ip to short variable name for logging purposes 
    
    $to = "contact@website.com";
    $subject= "request via website";
    $name = $_POST['name'];
    $phone = $_POST['phone'];
    $email = $_POST['email'];
    $street = $_POST['street'];
    $city = $_POST['city'];
    $firstlevel = $_POST['firstlevel'];
    $secondlevel = $_POST['secondlevel'];
    $thirdlevel = $_POST['thirdlevel'];
    
    $remarks = $_POST['remarks'];
    
    $message = "
    Name: $name
    Phone: $phone
    Email: $email
    
    Address: $street, $city
    
    Requested workshop:
    $firstlevel
    $secondlevel
    $thirdlevel
    
    Remarks: $remarks
    
    ";
      $mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
             $headers = "From: $email\r\n" .
             "MIME-Version: 1.0\r\n" .
                "Content-Type: multipart/mixed;\r\n" .
                " boundary=\"{$mime_boundary}\"";
             $message = "This is a multi-part message in MIME format.\n\n" .
                "--{$mime_boundary}\n" .
                "Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
                "Content-Transfer-Encoding: 7bit\n\n" .
             $message . "\n\n";
             foreach($_FILES as $userfile)
             {
                $tmp_name = $userfile['tmp_name'];
                $type = $userfile['type'];
                $name = $userfile['name'];
                $size = $userfile['size'];
                if (file_exists($tmp_name))
                {
                   if(is_uploaded_file($tmp_name))
                   {
                      $file = fopen($tmp_name,'rb');
                      $data = fread($file,filesize($tmp_name));
                      fclose($file);
                      $data = chunk_split(base64_encode($data));
                   }
                   $message .= "--{$mime_boundary}\n" .
                      "Content-Type: {$type};\n" .
                      " name=\"{$name}\"\n" .
                      "Content-Disposition: attachment;\n" .
                      " filename=\"{$fileatt_name}\"\n" .
                      "Content-Transfer-Encoding: base64\n\n" .
                   $data . "\n\n";
                }
             }
             $message.="--{$mime_boundary}--\n";
    if (mail($to, $subject, $message, $headers))
       echo "<b>Thanks for your request.</b><br>It will be processed very shortly, so I will get back to you soon.<br>Please stay healthy in the meantime.
        <br>&nbsp;<br>&nbsp;<br><blockquote class='bordered layout-2'><b>This was your request:</b>
        <br>&nbsp;<br>$name
        <br>$street, $city
        <br>$phone - $email
        <br>&nbsp;<br>$firstlevel, $secondlevel, $thirdlevel
        <br>&nbsp;<br>Remarks:<br>$remarks</blockquote>
    ";
    else
       echo "Your request has not been processed.<br>Please try again, filling in all fields.";
    ?>
    But it seems like $firstlevel, $secondlevel and $thirdlevel are not recognised as a value, because they are not in the sent mail nor the recap of the sent message.
    How to get these values work, please?
    Thanks.

  2. #2
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    923
    Thanks
    121
    Thanked 2 Times in 2 Posts

    Default

    Been playing around, and I really can't find anything unusual.
    Yet it still doesn't work. Here's the live work (form at the bottom): https://www.parisaspersiankitchen.com/workshops1.php
    Anyone, please?
    Last edited by chechu; 09-03-2020 at 07:23 PM.

  3. #3
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    621
    Thanks
    274
    Thanked 14 Times in 14 Posts

    Default

    Dear Chechu: This is just a guess, but perhaps your html form needs to be something like this... your form code does not seem to be making a selection from options. Please see if this helps. Aaron

    Code:
    <p><label>Requested Workshop:</label>
    <select name="workshop" size="1">
      <option value="lev1">Online Streaming</option>
      <option value="lev2">Home Setting</option>
      <option value="lev3">Company Event</option> 													
    </select>


    Code:
    $workshop = $_POST['workshop'];
    Requested Workshop: $workshop

Similar Threads

  1. Chained Select Script
    By mylcorp in forum Dynamic Drive scripts help
    Replies: 4
    Last Post: 12-05-2014, 06:36 PM
  2. Chained Select Menu
    By vidya in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 11-22-2008, 11:42 AM
  3. Chained Select Menu?
    By yeknoM in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 03-19-2008, 09:05 AM
  4. Help with Chained Select Menu
    By montero in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 05-25-2006, 11:55 PM
  5. Chained Select question
    By Corby in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 09-18-2005, 02:47 PM

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
  •