So I am rather new to coding in these languages, I am getting a good understanding of how to write in them but not how to troubleshoot well. I went on and found some videos and read some sites to understand how to get this to work, and got this HTML
<form id="Contact-form" method="post" action="contactform.php"> <input type="text" name="name" placeholder="Your Name" class="form-control" required> <input type="text" name="Mail" placeholder="Your E-mail" class="form-control" required> <input type="text" name="name" placeholder="Subject" class="form-control" required> <textarea name="message" placeholder="Message" rows="7" class="form-control" required></textarea> <button class="form-control submit" type="submit" name="sumbit"> Send message</button>
The PHP
<?php
if(isset($_POST['submit'])){{
    $name = $_POST['name'];
    $subject = $_POST['subject'];
    $mailFrom = $_POST['mail'];
    $message = $_POST['message'];
    
    $mailTo = "myhostprovided@email"
    $headers = "From: ".$mailFrom;
    $txt = "You have received an e-mail from " .$name. ".nn".$message;
        
        
    mail($name, $subject, $txt, $headers);
    header("Location: Contact.php?mailsend")
   }
I have it live and attempted to test send myself an email and I get a basic error (HTML Error 500) and no email, it changes the URL to “contactform.php” as expected. I followed the tutorials to the T, what am I doing wrong! Thank you for the help in advance
Advertisement
Answer
Please change the codes from
<?php
if(isset($_POST['submit'])){{
    $name = $_POST['name'];
    $subject = $_POST['subject'];
    $mailFrom = $_POST['mail'];
    $message = $_POST['message'];
    
    $mailTo = "myhostprovided@email"
    $headers = "From: ".$mailFrom;
    $txt = "You have received an e-mail from " .$name. ".nn".$message;
        
        
    mail($name, $subject, $txt, $headers);
    header("Location: Contact.php?mailsend")
   }
to
<?php
if(isset($_POST['submit'])){
    $name = $_POST['name'];
    $subject = $_POST['subject'];
    $mailFrom = $_POST['mail'];
    $message = $_POST['message'];
    
    $mailTo = "myhostprovided@email";
    $headers = "From: ".$mailFrom;
    $txt = "You have received an e-mail from " .$name. ".nn".$message;
        
        
    mail($name, $subject, $txt, $headers);
    header("Location: Contact.php?mailsend");
   }