Lethysek
Lethysek

Reputation: 39

Sending email with data from form

I have problem with simple contact box. I want to send informations from form to my email.

Already tried with register globals on and off (.httacess), tried with simple $formname and $_POST['formname'] but still getting email without form info.

<?php

        if ($action == "send"){//isset wyslij




    //if (!$name || !$email || !$phone || !$enquiry) {
        //$problem = TRUE;
       //echo("<p>You have to fill all form.</p>");
    //}     

    if (!$problem){


    $name = $_POST['name'];    
    $data = date("d.m.y");


    $message = "
    <p>Name: $name</p>
    <p>Phone: $phone</p>
    <p>Email: $email</p>
    <br>
    <p>Enquiry: $enquiry</p>";


$od = "[email protected]";
$content = $message;
$header = "From: $od \r\n";
$header  .= 'MIME-Version: 1.0' . "\r\n";
$header .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
     (mail('[email protected]', 'New message from website Angelzena', $content, $header));



                     echo("<br><p>Message has been sent.</p>");

    }else{
          echo("<p>Try <a href=contact.php>again</a></p>");
         }                    
}


?>



        <form action="contact.php?action=send" method="post" enctype="text/plain">
        <label  for="name">Name</label><input type="text" name="name" /></br></br>
        <label  for="email">Email</label><input type="text" name="email" /></br></br>
        <label  for="phone">Phone</label><input type="text" name="phone" /></br></br>
        <label  for="enquiry">Enquiry</label><textarea name="enquiry" cols="20" rows="10"></textarea></br></br>
        <input type="submit" id="contact_button" value="Send" />
        </form>

Upvotes: 0

Views: 154

Answers (1)

Michael Bates
Michael Bates

Reputation: 1934

<form action="contact.php?action=send" method="post" enctype="text/plain">

When POSTing forms the enctype attribute should be application/x-www-form-urlencoded or multipart/form-data.

PHP does not handle forms POSTed as text/plain.

Upvotes: 1

Related Questions