Form Not Submitting Text... Can't Figure Out Why... PLEASE HELP ME!

3 replies
Hi Warriors,

I recently set up a form on my website for clients to fill out. It's at my new site, which you can check out at:

Turbocharge Your Website's Sales With Copy That is Guaranteed to Get Results!

Down near the end there is a form to fill out and submit. Here's the problem:

I tested it by filling out the fields and hitting the submit button. The email comes through fine, but although the fields are listed (name, email etc) the information that I filled in was not... meaning that it's broken somewhere.

I had a look at the code and it SEEMS okay to me, so I'm not sure why this is happening.

By the way, the code calls a script called "contact.php" which is found at:

Contact email error

In case it's easier, though, I've included it here:

<?php
if ($_POST['name'] != "" && $_POST['email'] && $_POST['website'] && $_POST['miscellaneous'] ) {
$subject="Request for Copywriting Quote";
$ip=$_SERVER["REMOTE_ADDR"];
$host = $ip;
$mon=date(m);
$day=date(j);
$year=date(y);
$hour=date(g);
$min=date(i);
$sec=date(s);
$hour=$hour-2;
if($hour<=0) { $hour+=12; }
$ts = "$hour:$min:$sec on $day/$mon/$year";


$to="daniel@noriskcopy.com";

$body="

Name: = $name

Email Address (PLEASE DOUBLE-CHECK) = $email

Website (If You Have One): = $website

Please Briefly Describe the Type of Project You Require (Sales Letter, Autoresponder Emails, etc) = $whatis

Briefly Describe the Product or Service You Need Copy Written For: = $product

Anything Else You Think I Need to Know? = $miscellaneous


Host: $host
Time: $ts";

$email = "From: Form <$to>";
mail($to, $subject, $body, $email);
?>

<html>
<head>
<title>Email Sent</title>
</head>
<body bgcolor="#ffffff" text="#666666">

<p>&nbsp;</p>
<center>
<table border="1" cellpadding="3" cellspacing="0" width="400" bordercolor="#919191" bgcolor="#E6E6E6">
<tr>
<td width="100%">
<p><center><b><font color="#000000">Email was successfully sent to: <?php echo $to ?></font></b></center>

</td>
</tr>
</table>

</body>
</html>

<?php
} else {
?>

<html>
<head>
<title>Contact email error</title>
</head>

<body bgcolor="#ffffff" text="#666666">
<p><center>
<table border="1" cellpadding="3" cellspacing="0" width="400" bordercolor="#919191" bgcolor="#E6E6E6">
<tr>
<td width="100%">
<center>
<b>There was an error with processing the email.</b><br>
<p>
<font color="#FF0000">Errors where:</font><br>
<?php
If (!$_POST['name'])
echo "Name: field is empty<br>";

If (!$_POST['email'])
echo "Email Address (PLEASE DOUBLE-CHECK) field is empty<br>";

If (!$_POST['website'])
echo "Website (If You Have One): field is empty<br>";

If (!$_POST['miscellaneous'])
echo "Anything Else You Think I Need to Know? field is empty<br>";

?>
<p>
Email message wasn't sent

</td>
</tr>
</table>
</body>
</html>

<?php
}
?>
I consider myself to have a passing understanding of PHP coding but I just can't figure this one out for the life of me.

Can anyone help me out here?

Kind regards,

-Dan
#figure #form #submitting #text
  • Profile picture of the author esoomllub
    Assuming the code you provided is all the code to handle the post... register globals is off (as it should be for better security). In the email, you are using "$name", etc, but in the if statement you are using $_POST['name']. $name does not exist unless register globals is on (and future versions of PHP will not even allow this).

    Change the code in your $body declaration to reference the field names with the appropriate $_POST variable. So... inside of the email body, use {$_POST['name']} instead of $name. Use the curly brackets to guarantee that it gets interpreted correctly.
    Signature
    {{ DiscussionBoard.errors[792420].message }}
  • Profile picture of the author xiaophil
    Hi Dan,

    The variables $name, $email etc have not been assigned in the script and are therefore empty. The values you want are still in the $_POST array. Try putting some assignments like this at the top of the script:

    $name = $_POST["name"]
    $email = $_POST["email"]

    etc...

    after that you could tidy up by changing all further occurrences of $_POST["varname"] to $varname

    Regards,

    Phil
    {{ DiscussionBoard.errors[792423].message }}
  • Profile picture of the author Daniel Scott
    Hey guys,

    YOU'RE AWESOME!

    Thanks so much... this fixed the problem.

    You guys should put your PayPal address in the "buy me a beer" part so people like me can give you a couple of bucks for helping out.

    -Dan
    Signature

    Always looking for badass direct-response copywriters. PM me if we don't know each other and you're looking for work.

    {{ DiscussionBoard.errors[793797].message }}

Trending Topics