Php email form

Email is sending…
But not getting email in email inbox forBhis form what is my mistake…

<?php 
if ($_POST["email"]<>'') { 
    $ToEmail = 'example@example.com'; 
    $EmailSubject = 'Site contact form'; 
    $mailheader = "From: ".$_POST["email"]."\r\n"; 
    $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; 
    $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
    $MESSAGE_BODY = "Email: ".$_POST["email"].""; 
    $MESSAGE_BODY .= "Mobile: ".$_POST["mobile"].""; 
    $MESSAGE_BODY .="Message: ".nl2br($_POST["message"]).""; 
    mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); 
?> 
Your message was sent
<?php 
} else { 
}
?> de

HTML


<form method="post" action="send_mail.php">
<input type="email" name="email" placeholder="Email"><br><input type="tel"name="mobile" placeholder="Mobile">
<br><textarea cols="5" rows="5" placeholder="message" name="message">

Please heLp…

@shivkumar, this has been asked several times in the forums. This recent topic should help.

1 Like

How do you know? You don’t check the return from the mail() function to see whether it’s sending.

Also, don’t use your form-fillers email address as the “from” address, there are all sorts of problems involved in that. Send it from your own address, as you already use the reply-to header.

But even that doesn’t imply that the email is sending, just that mail() has given it to whichever OS binary is sending emails (e.g. the sendmail executable, or whatever is configured).

When I was submitted the form I redirected to that thank you page/Submitted successfully page…

:cry::cry::cry::cry::cry:~~~???

Never knew this operator existed.

I am not understand…

I am trying to make the point that it’s incorrect. There is no such thing as <>. Though < and > are both legitimate operators, mashing them together like that gives you the result you were saying and not the correct one that you want.

Nor me, I must say I’ve never seen it used in PHP sample code or on here, and so I’d presumed that it was necessary to use !=, but <> has the same effect, according to the doc at least.

I must say I hadn’t noticed your “or die()” function on the end of the line. But as @dormilich said, the return from mail() only checks whether it’s been able to push it off somewhere to be mailed, not that it’s actually gone anywhere.

I don’t use it in my own code but I have seen it a few times. I guess it could make numerical comparisons more readable. eg.

if ( 32 <> 47 ) { 

but doesn’t feel right to use for string comparisons eg.

if ( "foo" <> "bar" ) { 

looks like a problem waiting to happen. It probably isn’t, but it makes me feel uneasy.

Because “less than or greater than” in numerical context is equivalent to “not equal” (at least for the Math I’m used to) I routinely use !== instead.

3 Likes

I am from a background in BASIC programming of various dialects, and because that language generally uses <> rather than != for not-equal-to, whether in strings or numbers, it doesn’t look wrong to me. Maybe that’s why I didn’t even notice it in the posted code until @spaceshiptrooper mentioned it.

3 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.