Results 1 to 3 of 3

Thread: form needs "from"

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

    Default form needs "from"

    Hi all, for some reason this form stopped working, and someone said I should add a "from" field. No idea how to, so if anyone can help me out here, great!
    This is the code:
    Code:
    <?php
    
    $ip = $_SERVER['REMOTE_ADDR']; // get ip to short variable name for logging purposes 
    
    $to = "mail@mywebsite.com";
    $subject= "order home delivery via website";
    $name = $_POST['name'];
    $phone = $_POST['phone'];
    $email = $_POST['email'];
    $street = $_POST['street'];
    $city = $_POST['city'];
    $date = $_POST['date'];
    $delivery = $_POST['delivery'];
    $falafel = $_POST['falafel'];
    $kebab = $_POST['kebab'];
    $chicken = $_POST['chicken'];
    $frittata = $_POST['frittata'];
    $beanrice = $_POST['beanrice'];
    $beanriceveggie = $_POST['beanriceveggie'];
    $aubergine = $_POST['aubergine'];
    $beefcurry = $_POST['beefcurry'];
    $pistachio = $_POST['pistachio'];
    $rafaella = $_POST['rafaella'];
    $carrot = $_POST['carrot'];
    $almond = $_POST['almond'];
    $saffron = $_POST['saffron'];
    $jewelled = $_POST['jewelled'];
    $book = $_POST['book'];
    $remarks = $_POST['remarks'];
    
    $message = "
    Name: $name
    Phone: $phone
    Email: $email
    
    Address: $street, $city
    
    Time of delivery: $date
    Delivery: $delivery
    Book: $book
    
    Order: 
    $falafel
    $kebab
    $chicken
    $frittata
    $beanrice
    $beanriceveggie
    $aubergine
    $beefcurry
    $pistachio
    $saffron
    $jewelled
    $rafaella
    $carrot
    $almond
    
    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 order.</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 order:</b>
        <br>&nbsp;<br>$name
        <br>$street, $city
        <br>$phone - $email
        <br>&nbsp;<br>$book
        <br>&nbsp;<br>$delivery
        <br>delivery time: $date
        <br>&nbsp;<br>$falafel
        <br>$kebab
        <br>$chicken
        <br>$frittata
        <br>$beanrice
        <br>$beanriceveggie
        <br>$aubergine
        <br>$beefcurry
        <br>$pistachio
        <br>$saffron
        <br>$jewelled
        <br>$rafaella
        <br>$carrot
        <br>$almond
        <br>&nbsp;<br>Remarks:<br>$remarks</blockquote>
        <br>&nbsp;<br><a href='https://mywebsite.com/home-delivery.php' class='btn btn-outline-maincolor'>Missed something - go back</a>
    ";
    else
       echo "Your order has not been processed.<br>Please try again, filling in all fields.<br><a href='https://mywebsite.com/home-delivery.php'>&#187; go back</a>";
    ?>

  2. #2
    Join Date
    Mar 2011
    Posts
    2,170
    Thanks
    60
    Thanked 120 Times in 116 Posts
    Blog Entries
    4

    Default

    Hey chechu! Can you give any more info on this issue? I did a quick check and there's no syntax errors or anything like that.

    Some useful info could be:
    What happens when the code runs?
    Are there any errors / log outputs?
    Does it print the "Thanks" or the "Not Processed"?
    Can you check your mail server to see whether it's sending? (e.g., is it not working because the target isn't receiving it, or because the sender isn't sending it?)

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

    Default

    Thanks for your reply, keyboard.

    Feel free to fill in the form: https://www.parisaspersiankitchen.com/home-delivery.php
    It takes you to the "not sent" message, and indeed I do not receive it.
    Regarding your mail server question: no idea how to get that info.

    It also seems like it is not working because it does not go with the latest php version.
    How to adjust it, please?
    Thanks.
    Last edited by chechu; 05-26-2021 at 03:57 PM.

Similar Threads

  1. "Guestbook"...actually "leave comments" html form
    By igotregistered in forum HTML
    Replies: 2
    Last Post: 02-15-2013, 12:34 PM
  2. Replies: 1
    Last Post: 12-23-2011, 08:40 PM
  3. Replies: 0
    Last Post: 04-11-2009, 08:48 AM
  4. Replies: 5
    Last Post: 12-15-2007, 02:53 PM
  5. Replies: 1
    Last Post: 06-25-2007, 12:31 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
  •