-1

I've followed a PHP contact form tutorial from https://1stwebdesigner.com/php-contact-form-html/, everything prints out fine in the email that's sent to the recipient, except the selected value in the dropdown box.

So how exactly could I get one of the 4 values to be printed in the email?

Here is a snippet from the HTML file:

<form action="emailform.php" method="POST">
    <p>Full Name</p> <input type="text" name="name">
    <p>Email</p> <input type="text" name="email">

    <p>Subject</p>
    <select name="list">
        <option value="booking">Booking Query</option>
        <option value="payment">Request Payment Details</option>
        <option value="error">Report Website Error</option>
        <option value="other">Other</option>
    </select>
    <br />

    <p>Message</p><textarea name="message" rows="6" cols="25"></textarea><br />
    <input type="submit" value="Send">
</form>

And the PHP file:

<?php
    $name = $_POST['name'];
    $email = $_POST['email'];
    $list = $POST['list'];
    $message = $_POST['message'];
    $formcontent="From: $name \n Subject: $list \n Message: $message";
    $recipient = "email@example.com";
    $subject = "Aeron Valley Classic Hire";
    $mailheader = "From: $email \r\n";
    mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
    echo "Thank You!" . " -" . "<a href='contact.html' style='text-decoration:none;color:#B22222;'> Return Home</a>";
?>

I'm not very good at this, but although I've followed every step of the tutorial I do wonder how the PHP code actually knows what the values are and how to display them?

Any help would be appreciated.

L.Davies
  • 11
  • 6

1 Answers1

0

u typoed ur POST request for the list

$list = $POST['list'];

should be

$list = $_POST['list'];
Ralph
  • 337
  • 4
  • 13
  • When the answer is "you made a typo, add one character", please flag the question as Off-topic: typo and inform the OP with a comment instead of answering. These types of questions are not helpful to future researchers and are off-topic for this very reason. – mickmackusa Mar 30 '19 at 11:17
  • 1
    @mickmackusa ahh alright, didn't know about that so thanks – Ralph Mar 30 '19 at 14:30