What is the problem with an email form when receiving a white page?


csummerfield
Asked:
2013-05-21 9:22 am EST

Hits: 438
I have created a one field PHP comment form to be sent via email. It's being sent and received, but it is not giving me the message details. The page on the website is located at http://www.naturaldogremedies.net

HTML Form
<form name="form1" method="post" action="send_contact.php">
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<td width="82%"><p2 style="font-weight: bold">My Shelter</p2>
<textarea name="detail" cols="8" id="detail"></textarea></td>
</tr>
<tr>
<td colspan="3" style="text-align: center"><p2><input type="submit" name="Submit" value="Submit"></p2></td>
</tr>
</table>
</form>

PHP Action Script

<?php
// Contact subject
$subject ="Contact Form";

// Detail
$message ="$detail";

// Enter your email address
$to ="info@naturaldogremedies.net";

$send_contact=mail($to,$subject,$message);


// Check, if message sent to your email
// display message "We've received your information"
if($send_contact){
echo "I received your information";
}
else {
echo "ERROR";
}
?>

Thanks for your help.

You must login before you can ask a follow up question.

You must login before you can submit an answer.

OTHER ANSWERS

0

jamesr
Staff
5,889 Points
2013-05-21 12:29 pm EST
Hello csummerfield!

In order for your form variables to receive the data, you will need to use one of the following to get them.

$_GET['variable'];
$_POST['variable'];
$_REQUEST['variable'];

I revamped your code so it works. Please see the folloowing.
<?php
if (isset($_REQUEST['Submit'])){
$subject = "Contact Form";
$message = 'You received the comment ' . $_REQUEST['detail'] . ' from your site! ';
$to ="docs@inmotionhosting.com";
$send_contact = mail($to,$subject,$message);

if($send_contact){
echo '<p>I received your information</p><p>You typed: ' . $_REQUEST['detail'] . '</p>';
}else{echo 'There was a problem with the email!';}
}else {?>
<form name="form1" method="post">
My Shelter<br />
<textarea name="detail" cols="20" id="detail"></textarea><br />
<input type="submit" name="Submit" value="Submit">
</form>
<?php } ?>

Add the code to one php page. The code will run from the same page as the form. You can add or change it as necessary. You will want to review my article on How to create a custom PHP contact form with validation. The form you have will accept any data. you will want to add validation to it to prevent spam bots from hitting the form

Best regards,
James R

You must login before you can post a comment about this answer.

Hey James, You da man! Thank you so much. I can't tell you how many hours I put in researching and trying it out. You have certainly made my day. Thanks again.
csummerfield
8 Points
2013-05-21 3:03 pm EST
Like this Question?

Related Articles

It looks like there are no related articles.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!