Go Back   WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk
Register Blogs FAQ Social Groups CalendarHelp Desk

Reply
 
LinkBack Thread Tools
Old 05-17-2009, 09:15 AM   #1
The Cake Is A Lie
War Room Member
 
Daniel Scott's Avatar
 
Join Date: Oct 2004
Location: Mackay, QLD, Australia
Posts: 2,165
Thanks: 291
Thanked 641 Times in 370 Posts
Contact Info
Send a message via Skype™ to Daniel Scott
Default Form Not Submitting Text... Can't Figure Out Why... PLEASE HELP ME!

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:

Quote:
<?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   Reply With Quote
Old 05-17-2009, 03:12 PM   #2
Warrior Member
War Room Member
 
Join Date: May 2009
Location: Maidens, VA
Posts: 25
Thanks: 7
Thanked 3 Times in 3 Posts
Social Networking View Member's Twitter Profile 
Default Re: Form Not Submitting Text... Can't Figure Out Why... PLEASE HELP ME!

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   Reply With Quote
Old 05-17-2009, 03:12 PM   #3
Took The Red Pill
War Room Member
 
xiaophil's Avatar
 
Join Date: Apr 2006
Location: Here and Now
Posts: 374
Thanks: 124
Thanked 106 Times in 64 Posts
Contact Info
Send a message via Skype™ to xiaophil
Default Re: Form Not Submitting Text... Can't Figure Out Why... PLEASE HELP ME!

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   Reply With Quote
Old 05-18-2009, 03:35 AM   #4
The Cake Is A Lie
War Room Member
 
Daniel Scott's Avatar
 
Join Date: Oct 2004
Location: Mackay, QLD, Australia
Posts: 2,165
Thanks: 291
Thanked 641 Times in 370 Posts
Contact Info
Send a message via Skype™ to Daniel Scott
Default Re: Form Not Submitting Text... Can't Figure Out Why... PLEASE HELP ME!

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   Reply With Quote
Reply

  WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk

Tags
figure, form, submitting, text

Thread Tools

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 05:36 PM.