Hey everyone,
this is my first experience working with PHP to bear with me. I wrote a form handler to process data on my website and installed an apache server to run it on. Everything works fine until I submit the form, and the code either appears on the following page or displays a blank page. I’m not sure if this is an issue in my code or the way I stored it in htdocs. below is a snippet of my code:
<?php
if(isset($_POST['submit'])){
$name=$_POST['name'];
$lname=$_POST['lname'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$msg=$_POST['msg'];
$to='[email protected]';
$subject='Submission';
$message="First Name: ".$name."\n". "Last Name: ".$lname."\n" ."Phone: "."\n". "Wrote the following: "."\n\n".$msg;
$headers="From: ".$email;
if (mail($to, $subject, $message, $headers)){
echo "<h1>Thanks for reaching out!</h1>";
}
else{
echo "Something went wrong";
}
}
?>