dimanche 5 juillet 2020

My contact form submit button opens the php file instead of running it [duplicate]

I am trying to making a simple website using HTML, CSS, and PHP and am looking to add a contact form at the bottom of the page. I have linked the PHP file to the contact form and have gotten all the code, but when I go to submit the form and click on the submission button, it opens the PHP file. Why is this happening, am I doing something wrong?

<?php

if(isset($_POST['submit'])){
    $name = $_POST['name'];
    $mailFrom = $_POST['mail'];
    $message = $_POST['message'];

    $mailTo = "devlai23@bergen.org";
    $headers = "From: ".$mailFrom;
    $txt = "You have received an email from ".$name.".\n\n".$message;
    
    mail($mailTo, $name, $txt, $headers);
    header("Location: index.html?mailsend");
}



Aucun commentaire:

Enregistrer un commentaire