Hello all! I'm fairly new here, so apologies if I'm posting in the wrong place.
I'm just starting to code in PHP and currently am coding a page for my bass guitar tutorial website. This particular page is a song request form, where users can fill out a song they would like to see turned into a video tutorial. I am just about to go punch a wall because of all the error messages I keep receiving. I fix one, and then another occurs, and so on.
Here's a screenshot of the current error I am receiving:
[ATTACH]5201[/ATTACH]
I'm not sure why I am getting these errors, I believe everything is defined as a variable...
Here is my current code:
<?php
$to = 'rockittonite@gmail.com';
$subject = 'Song Request';
$message = $name . " " . $email . " " . $song . " " . $artist . " " ;
$headers .= 'To: Amanda <rockittonite@gmail.com';
mail($to, $subject, $message, $headers);
$nameErr = $emailErr = $songErr = $artistErr = "";
$name = $email = $song = $artist = $comment = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["name"])) {
$nameErr = "Name is required.";
}
else {
$name = test_input($_POST["name"]);
}
if (empty($_POST["email"])) {
$emailErr = "Email is required.";
}
else {
$email = test_input($_POST["email"]);
}
if (empty($_POST["song"])) {
$songErr = "A song is required.";
}
else {
$song = test_input($_POST["song"]);
}
if (empty($_POST["artist"])) {
$artistErr = "An artist or band is required.";
}
else {
$artist = test_input($_POST["artist"]);
}
if (empty($_POST["comment"])) {
$comment = "";
}
else {
$comment = test_input($_POST["comment"]);
}
}
?>
<center><form method= "post" action=<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>>
Name: <input type = "text" name= "name">
<span class= "error">* <?php echo $nameErr;?></span> <br><br>
Email: <input type = "text" name= "email">
<span class= "error">* <?php echo $emailErr;?></span> <br><br>
Song: <input type = "song" name= "song">
<span class="error">* <?php echo $songErr;?></span> <br><br>
Artist: <input type = "artist" name="artist">
<span class="error">* <?php echo $artistErr;?></span> <br><br>
Comment: <textarea name="comment" rows="3" cols="20"></textarea> <br><br>
<input type ="submit" name="submit" value="Submit"> <br><br>
</form></center>
Any help would be great! Like I said, I am new to this, so it's most likely a rookie mistake, haha.
error.png