Hi All,
I'm just starting out with PHP so this is all a little confusing still. I'm trying to make a mail form, and have gone through several issues, mostly getting the emails to send, but they finally are sending, but now they are blank, or rather the input values are missing.
I'm using Godaddy as a host and a Linux server, I figured I'd add that.
This is the HTML code:
<h1>Contact</h1>
<form action="sendmail.php" method="post">
Your Name:<br />
<input type="text" name="name" /><br /><br />
Your E-mail Address:<br />
<input type="text" name="email" /><br /><br />
Your Phone Number:<br />
<input type="text" name="phone" /><br /><br />
Message:<br />
<textarea class="message"></textarea><br />
<br /><br />
<input type="submit" value="Send">
<input type="reset" value="Reset">
</form>
This is the original php I used:
<?php
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
$name = $_REQUEST['name'] ;
$phone = $_REQUEST['phone'] ;
$totalmessage = "
Name: $name \n
Phone: $phone \n
Message: $message \n";
mail( "myemailaddress@gmail.com", "Contact Drew Message", $totalmessage, "From: $email" );
header( "Location: http://www.dhlevinson.com/thankyou.html" )
?>
I was consistently getting blank emails or well they would actually say:
Name:
Phone:
Message:
but without any of the values.
I had originally thought that this was a php issue, but then I added this check (see code below) and now when I fill out the form to test I'm getting the contact (the page that the form is one) page over and over again, which I'm guessing means that the values aren't registering when I put them in.
Here is the revised php code:
<?php
$email = $_REQUEST["email"] ;
$message = $_REQUEST["message"] ;
$name = $_REQUEST["name"] ;
$phone = $_REQUEST["phone"] ;
$totalmessage = "
Name: $name\n
Phone: $phone\n
Message: $message \n";
if (!isset($_REQUEST["email"])) {
header( "Location: http://dhlevinson.com/contact.html" );
}
elseif (empty($email) || empty($message)) {
header( "Location: http://dhlevinson.com/error.html" );
}
else {
mail( "myemailaddress@gmail.com", "Contact Drew Message", $totalmessage, "From: $email" );
header( "Location: http://www.dhlevinson.com/thankyou.html" );
}
?>
I'm not even sure this is a php issue, it might be an issue with the html of the form, but I figured I'd give this thread a shot as I'm completely stumped with this.
Thank you in advance to anyone who replies!