Can not get form to work

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dlparker47
Forum Newbie
Posts: 3
Joined: Wed Jul 08, 2009 3:20 pm

Can not get form to work

Post by dlparker47 »

I am new to PHP, but I have had success creating forms for email and the like, but today, I have been at this for hours and can not get this form to work. Could someone look at this and see if there is something that I am missing. I must be blind or jaded Help :banghead:

http://custom-homedesign.com/survey.html
http://custom-homedesign.com/send_survey.php

Thanks,
Doug Parker

Absolute Web Hosting and Design, LLC
http://absolute-webhosting.com
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: Can not get form to work

Post by Eric! »

Your php code has a parsing error and the errors are not set to display. You will have to post your code if you want any help. Please use the proper code=php tags when you post your code.
dlparker47
Forum Newbie
Posts: 3
Joined: Wed Jul 08, 2009 3:20 pm

Re: Can not get form to work

Post by dlparker47 »

Thanks,

Here is the code:

Code: Select all

<?php
if (($_POST[name] == "") ||
    ($_POST[email] == "")) {
    header("Location: survey.html");
    exit;
}
 
$msg = "E-mail sent from Unique Home Designs\n";
$msg .= "Sender's Name:\t$_POST[name]";
$msg .= "Sender's Email:\t$_POST[email]";
$msg .= "Sender's Phone:\t$_POST[phone]";
$msg .= "Style of Home:\t$_POST[styleofhome]";
$msg .= "Aprox Sq Ft:\t$_POST[sq.ft]";
$msg .= "Bedrooms:\t$_POST[bedrooms]";
$msg .= "Baths:\t$_POST[baths]";
$msg .= "Garage:\t$_POST[garage]";
$msg .= "Explain:\t$_POST[explain]\n";
$msg .= "Roof:\t$_POST[roof]";
$msg .= "Lot:\t$_POST[lot]";
$msg .= "Number of Plans:\t$_POST[numberofplans]";
$msg .= "3D:\t$_POST[3D]";
$msg .= "Owner:\t$_POST[owner]";
 
$to = "dlparker47@gmail.com";
$subject = "Web Site Survey";
$mailheaders = "From: <support@custom-homedesign.com>\n";
$mailheaders .= "Reply_To: $_POST[email]\n";
 
mail($to, $subject, $msg, $mailheaders);
 
?>

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>Feedback Survey Form</title>
  <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
</head>
<body>

Code: Select all

<h1>The following e-mail has been sent:</h1>
<strong>Your Name:</strong><br />

Code: Select all

<?php echo "$_POST[name]"; ?>

Code: Select all

<strong>Your E-mail Address:</strong><br />

Code: Select all

<?php echo "$_POST[email]"; ?>

Code: Select all

<strong>Your Phone Number:</strong><br />

Code: Select all

<?php echo "$_POST[phone]"; ?>
<strong>Style of Home:</strong><br />

Code: Select all

<?php echo "$_POST[styleofhome]"; ?>

Code: Select all

<strong>Aprox Sq Ft:</strong><br />

Code: Select all

<?php echo "$_POST[sq.ft]"; ?>

Code: Select all

<strong>Bedrooms:</strong><br />

Code: Select all

?php echo "$_POST[bedrooms]"; ?>

Code: Select all

<strong>Baths:</strong><br />

Code: Select all

<?php echo "$_POST[baths]"; ?>

Code: Select all

<strong>Garage:</strong><br />

Code: Select all

<?php echo "$_POST[garage]"; ?>

Code: Select all

<strong>Explain:</strong><br />

Code: Select all

<?php echo "$_POST[explain]\n"; ?>

Code: Select all

<strong>Roof:</strong><br />

Code: Select all

<?php echo "$_POST[roof]"; ?>

Code: Select all

<strong>Lot:</strong><br />

Code: Select all

<?php echo "$_POST[lot]"; ?>

Code: Select all

<strong>Number of Plans:</strong><br />

Code: Select all

<?php echo "$_POST[numberofplans]"; ?>

Code: Select all

<strong>3D:</strong><br />

Code: Select all

<?php echo "$_POST[3D]"; ?>

Code: Select all

<strong>Owner:</strong><br />

Code: Select all

<?php echo "$_POST[owner]"; ?>
</body>
</html>
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: Can not get form to work

Post by Eric! »

I assumed when I tried your link and entered random data and got a blank screen it was due to an error, but after seeing your code it did what it was supposed to do when it finished, nothing. Add a header("Location: thankyou.html"); or something to tell people it worked.

So I assume you aren't getting any email messages? Unfortunately your code tags weren't right for the form, so I can't read it. I could go back to your link to see the source, but it is probably better just to ask you to add before mail()

Code: Select all

echo 'TO:'.$to.'<br>Subj:'.$subject.'<br>MSG:'.$msg.'<br>Headers:'.$mailheaders;
Post Reply