I've used HTML and JavaScript for years and am finally trying PHP. There are a gazillion tutorials on the web telling you how to code a simple form on a webpage that sends the input in an e-mail.
The problem is that they all end up with a blank white screen and a PHP print message like: Form Sent
They all do that, but it's so lame. Who wants to end up with a black screen and no links! You should end up on a page of your website.
So I'm trying to direct it to the URL of one of my webpages, and inserted the code you see below. I understand it is failing because you can only use header location at the start of your php file. But you don't want to change the location before executing the php?
Thank you, Peter
<html><body>
<?php
$to="info@columbiariverpetpartners.org";
$subject="Membership Application";
$name=$_REQUEST['name'];
$FirstName=$_REQUEST['FirstName'];
$LastName=$_REQUEST['LastName'];
$FullName="$FirstName $LastName";
$message="First Name: $FirstName\nLast Name: $LastName";
$headers="From: $FullName";
$sent=mail($to,$subject,$message,$headers);
if ($sent) {header("Location: sent.html");
exit}
else {header("Location: failed.html");
exit}
?>
</body>
</html>