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!
I have the following form code, I have a honey pot form field which is hidden with css called 'Email' The problem is the email isn't being sent, can anyone point me in the right direction.
<?
$mail_content =
"Dear Joe Bloggs\n\n".
"Please could you provide me with a quote, my details are as follows:\n\n".
"Title: ".$_POST['Contact_Title']."\n".
"Contact Name: ".$_POST['Contact_Name']."\n".
"Company Name: ".$_POST['Company_Name']."\n".
"Postcode: ".$_POST['Postcode']."\n\n".
"E-mail: ".$_POST['Email2']."\n".
"Telephone: ".$_POST['Contact_Telephone']."\n".
"How did you find us: ".$_POST['find_us']."\n\n".
"Im Interested: ".$_POST['Interested']."\n\n".
"Message body: ".$_POST['Message_Body']."\n";
echo nl2br($mail_content);
// Check the spam trap to see if it has data in it. If it does, don't bother mailing the form.
if (!isset($_POST['Email'])) {
mail("my@email.com", $Interested, $mail_content);
}
?>
<?php
$mail_content = (
"Dear Joe Bloggs\n\n".
"Please could you provide me with a quote, my details are as follows:\n\n".
"Title: ".$_POST['Contact_Title']."\n".
"Contact Name: ".$_POST['Contact_Name']."\n".
"Company Name: ".$_POST['Company_Name']."\n".
"Postcode: ".$_POST['Postcode']."\n\n".
"E-mail: ".$_POST['Email2']."\n".
"Telephone: ".$_POST['Contact_Telephone']."\n".
"How did you find us: ".$_POST['find_us']."\n\n".
"Im Interested: ".$_POST['Interested']."\n\n".
"Message body: ".$_POST['Message_Body']."\n"
);
echo nl2br($mail_content);
// Check the spam trap to see if it has data in it. If it does, don't bother mailing the form.
if(!isset($_POST['Email']))
{
mail("my@email.com", $Interested, $mail_content);
}
?>
I have the following form code, I have a honey pot form field which is hidden with css called 'Email' The problem is the email isn't being sent, can anyone point me in the right direction.
Jcart wrote:Eeek! The usage of @ should be avoided unless completely unnecesary. There is a reason it is throwing a notice, because you are doing something wrong!
Haha.
My views on this matter are different however, so we will respectfully disagree.
P.S. the @ is an "Error control operator" -- not the supress errors because I'm lazy operator
It is not a matter of opinion, it is a matter of what is right and wrong. You are supressing an error because you are using a variable that does not exist. In fact, it is proper programming to ensure a variable exists before using it.
And if you disagree with that.. well... lets just leave it there
P.S., check your PHP error logs. They are probably massive if this is how you feel.
Jcart wrote:Actually empty() provides the added benefit of checking the variable has a (positive) value, so that is incorrect.
...
pytrin wrote:empty() and isset() are not suppressors - they give you a chance to perform error handling. In general, it is bad practice to suppress errors.
I didn't say isset is a suppressor.
empty however, is a suppressor.
http://php.net wrote: empty() is the opposite of (boolean) var, except that no warning is generated when the variable is not set.
empty() does not supress the error, it will gracefully checks for the existance of the variable before using it. I'll have to look up the source code if this continues on, because I'll be damned if the PHP core generates internal errors in the source.
However, calling empty() an error supressor simply isn't right. It's purpose is not to supress errors.