Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 17th May 2009, 08:15 AM   #1
The Cake Is A Lie
War Room Member
 
Daniel Scott's Avatar
 
Join Date: 2004
Location: Mackay, QLD, Australia
Posts: 1,656
Thanks: 293
Thanked 927 Times in 481 Posts
Default
Form Not Submitting Text... Can't Figure Out Why... PLEASE HELP ME!
Share on: 
fb share twitter share gplus share more share

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
Daniel Scott is offline  
Unread 17th May 2009, 02:12 PM   #2
Active Warrior
War Room Member
 
Join Date: 2009
Location: Maidens, VA
Posts: 42
Thanks: 21
Thanked 12 Times in 9 Posts
Default
Re: Form Not Submitting Text... Can't Figure Out Why... PLEASE HELP ME!
Share on: 
fb share twitter share gplus share more share

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.
esoomllub is offline  
Unread 17th May 2009, 02:12 PM   #3
HyperActive Warrior
War Room Member
 
Join Date: 2006
Posts: 366
Thanks: 117
Thanked 104 Times in 62 Posts
Default
Re: Form Not Submitting Text... Can't Figure Out Why... PLEASE HELP ME!
Share on: 
fb share twitter share gplus share more share

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
xiaophil is offline  
Unread 18th May 2009, 02:35 AM   #4
The Cake Is A Lie
War Room Member
 
Daniel Scott's Avatar
 
Join Date: 2004
Location: Mackay, QLD, Australia
Posts: 1,656
Thanks: 293
Thanked 927 Times in 481 Posts
Default
Re: Form Not Submitting Text... Can't Figure Out Why... PLEASE HELP ME!
Share on: 
fb share twitter share gplus share more share

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
Daniel Scott is offline  
Closed Thread


Bookmarks

Tags
figure, form, submitting, text


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 07:51 AM.