0

I want the form to send the contents to my email, instead it's just displaying my php code in a new window, can anyone help? here is the code:

Index

<form action="send.php" method="POST">
  Name: <br><input type="text" name="name"><br><p>
  Request: <br><textarea name="request"></textarea><p>
  <input type="submit" name="submit" value="Send!">
</form>

PHP:

<?php
$name = $_POST['name'];
$request = $_POST['request'];

$to = "myemail@email.co.uk";
$subject = "It's just a test";
$body = "This is just a test to see if things are working okay \n\n $request";

mail ($to,$subject,$body);

echo "Message sent!"
?>
Chris
  • 4,672
  • 13
  • 52
  • 93

1 Answers1

0

Few tips for beginners

  1. First Configure your Xampp form send email How to configure XAMPP to send mail from localhost?
  2. Check if the data is coming to send.php by print_r($_POST)
  3. Follow this tutorial for sending email from here
xitas
  • 1,136
  • 3
  • 23
  • 47