Lethysek
Lethysek

Reputation: 39

$_POST doesnt work

I have a simple contact me script, which fires an email on submit. The email is sent, but there are no form values in the email (name: empty, ...).

Why doesn't my contact script work?

<?php
    if ($action == "send") //isset wyslij
    {
        if (!$_POST[name] || !$_POST[email] || !$_POST[phone] || !$_POST[enquiry])
        {
            $problem = TRUE;
            echo("<p>You have to fill all form.</p>");
        }       

        if (! $problem)
        {
            $data = date("d.m.y");
            $message = "
                <p>Name: $_POST[name]</p>
                <p>Phone: $_POST[phone]</p>
                <p>Email: $_POST[email]</p>
                <br>
                <p>Enquiry: $_POST[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', $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: 107

Answers (2)

Whocares
Whocares

Reputation: 96

simply remove the "enctype" argument from the HTML form code and try again?

Upvotes: 0

DevZer0
DevZer0

Reputation: 13525

Valid values for enctype in tag are:

application/x-www-form-urlencoded
multipart/form-data

you have text/plain and thats why it's not working.

Upvotes: 2

Related Questions