ellaaur ellaaur -3 years ago 123
HTML Question

Why am I getting "Undefined variable: POST" in C:\wamp64\www\form\appointmentform.php notice here?

I'm a beginner with php and I am trying to test out my contact form on localhost. When I hit submit I'm getting this notice: "Notice: Undefined variable: POST in C:\wamp64\www\form\appointmentform.php on line 5" I saw a suggestion on here to use $_POST instead of $POST, however that's what I'm doing so I can't figure out the problem here.

Here is my HTML code:

<!doctype html>
<form action="appointmentform.php" method="POST">
<select name="dropdown" class="float-left">
<option value="option">Select a Service</option>
<option value="Facial">Facial</option>
<option value="Threading">Threading</option>

<input class="float-right" placeholder = "mm/dd/yy" aria-invalid="false" type="date" name="date">
<input class="right" placeholder = "Time" aria-invalid="false" type="time" name="time">
<p class="sub-tit">Personal Information</p>
<input class="float-left" placeholder="Full Name" type="text" name="name">
<input class="float-left" placeholder="Phone" type="text" name="phone">
<input type="text" placeholder="Email" name="email">
<input type="submit" class="qbuuton float-right" value="Submit">

And here is my PHP code:

$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$dropdown = $POST['dropdown'];
$date = $_POST['date'];
$time = $_POST['time'];
$formcontent="From: $name \n Phone: $phone \n Email: $email \n Service: $dropdown \n Date: $date \n Time: $time";
$recipient = "email@gmail.com";
$subject = "Customer Appointment Request";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";

Answer Source

You're still using $POST in one of your assignments.

$dropdown = $POST['dropdown']; should be $dropdown = $_POST['dropdown'];

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download