0

I am working on a website that has a simple contact form in which the website visitor can enter his name, E-mail address and his message and all of those data will be sent to a destination E-mail, I tried several solutions but I can't find the result in the destination E-mail.

PS: I have my HTTP SERVER up and running using EasyPhp

HTML SOURCE

<form method="post" action="C:\Users\myPC\Desktop\WEBSITE\root\assets\php\contact.php">
     <div>
          <label for="name">Name: </label>
          <input type="text" id="name" name="name">
     </div>
     <div>
          <label for="email">Email: </label>
          <input type="email" id="email" name="email">
     </div>
     <div>
          <label for="message">Message: </label>
          <textarea id="message" name="message" rows="4"></textarea>
     </div>
     <button type="submit" name="send">Submit</button>
</form>

PHP SOURCE

<?php 
      $name = $_POST['name']; //user input name
      $email = $_POST['email']; //user input email
      $message = $_POST['message']; //user input message

      $secured_name = htmlspecialchars($name);
      $secured_email = htmlspecialchars($email);
      $secured_message; = htmlspecialchars($message);

      $formcontent="From: $secured_name \n Message: $secured_message"; //E-mail body (username + e-mail message)
      $recipient = "myservice@outlook.com"; //support service EMAIL
      $subject = "Contact request - website"; //E-mail subject
      $mailheader = "From: $secured_email \r\n"; //sender E-mail

      //action
      if (isset($_POST["send"])) {
         mail($recipient, $subject, $formcontent, $mailheader) 
         or die("Error!");
      }
?>
Thorvald
  • 3,424
  • 6
  • 40
  • 66

0 Answers0