'I have a working email form but I need to add more fields and can't get it to work. I add **** by the coded I added in the php file

Below is the HTML and PHP.

Im working on making an estimate request form like the one here: https://centralohiogrimefighters.com/quote.html this one is through Ipower and isn't reliable so I made another one from you tube https://www.youtube.com/watch?v=GAe2nZpI39c

This one works with the 4 fields from the video fine. It wont work when I add more fields. I need to add 17 check box field and 6 more fields. I have added 2 test fields. 1 is a check box name=test1 and a text box name=test. I have tried may ways from google and you tube. This is the video I washed to get the form. Thanks for your help

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <title>Contact form</title>
 <link href="https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600&family=Poppins&display=swap" rel="stylesheet">
 <link rel="stylesheet" href="ccs/style1.css">
</head>
<body>
 <div class="container">
     <h1>Contact Me</h1>
     <p>Feel free to contact us and we will get back to you as soon as we can.</p>
     <form action="php/mail.php" method="POST">
        
       <label for="name">Name:</label>
         <input type="text" name="name" id="name">
        
       <label for="email">Email:</label>
         <input type="email" name="email" id="email">
        
         <label for="subject">Suject:</label>
         <input type="text" name="subject" id="subject">
         
         <label for="message">Message</label>
         <textarea name="message" cols="30" rows="10"></textarea>
         
         <label for="test1">Test1</label>
         <input type="checkbox" name="test1" >
         
         <label for="test">Test</label>
         <textarea name="test" cols="30" rows="2"></textarea>
         
         
         <input type="submit" value="Send">
         
     </form>
 </div>
</body>
</html>

Below is my PHP file (mail.php)

<?php

echo "<pre>";


print_r($_POST);


echo '</pre>';


$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];

$message = $_POST['test'];       **** This is my test fields 
$message = $_POST['test1'];





$mailheader = "From:".$name."<".$email.">\r\n";


$recipient = "[email protected]";

mail($recipient, Quote_request_from_COGF_site,  $message, $mailheader)  or die("Error!");



echo'message sent
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Contact form</title>
    <link href="https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600&family=Poppins&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="container">
        <h1>Thank you for contacting me. I will get back to you as soon as possible!</h1>
        <p class="back">Go back to the <a href="https://centralohiogrimefighters.com/Untitled-2.html">homepage</a>.</p>
        
    </div>
</body>
</html>
';


?>



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source