tmayder Posted May 17, 2010 Share Posted May 17, 2010 I am really glad to see you all here! I thought I knew enough about php to make this simple script work, but nothing is too easy these days!! Even though I do not use php a lot, I have made much tougher forms work and I am just not sure what I am missing here. When a site visitor types in their email address to subscribe to a newsletter, I get back a blank email, they get thanked and a message saying the submission was successful. I am reusing another form and wonder if too much info is causing the problem? I have tried to remove the extra stripslashes (I only need mail) and the Body info, but I start getting errors. HTML: <form id="emailform" name="emailform" method="post" action="contactengine.php"> <input type="text" name="email" id="email" style="width:200px;" value="Enter Your Email" onfocus="if (this.value == 'Enter your Email') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Enter your Email';}"/> <input name="submit" type="submit" id="button" value="" /> </form> PHP (the original one): <?php $EmailFrom = "[email protected]"; $EmailTo = "[email protected]"; $Subject = "Subscribe to InSafe Consulting Ltd Newsletter"; $Name = Trim(stripslashes($_POST['Name'])); $Email = Trim(stripslashes($_POST['Email'])); $Comments = Trim(stripslashes($_POST['Comments'])); // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Email: "; $Body .= $Email; $Body .= "\n"; $Body .= "Message: "; $Body .= $Comments; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); } if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.html\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">"; } ?> All I am really looking for is to have their email address entered and sent back to me. Thanks in advance for any help and suggestions! t Link to comment https://forums.phpfreaks.com/topic/202098-blank-form-mail-send/ Share on other sites More sharing options...
beta0x64 Posted May 17, 2010 Share Posted May 17, 2010 Try passing it directly without trim and stripslashes... This will show if that is the problem. Link to comment https://forums.phpfreaks.com/topic/202098-blank-form-mail-send/#findComment-1059807 Share on other sites More sharing options...
tmayder Posted May 19, 2010 Author Share Posted May 19, 2010 Thanks beta0x64, but this changed nothing. We are still getting blank returns. Link to comment https://forums.phpfreaks.com/topic/202098-blank-form-mail-send/#findComment-1060707 Share on other sites More sharing options...
kenrbnsn Posted May 19, 2010 Share Posted May 19, 2010 PHP is case sensitive. In the HTML you have name="email", but in the PHP code you're looking for $_POST['Email'] Pick one or the other. Also, I don't see the input line for the $_POST['Name'] Ken Link to comment https://forums.phpfreaks.com/topic/202098-blank-form-mail-send/#findComment-1060718 Share on other sites More sharing options...
bulrush Posted May 19, 2010 Share Posted May 19, 2010 $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); I'm not sure the <> around $EmailFrom conforms to email standards. I've never received an email like that, with less than or greater than in the From field. And are you sure you need the "From:" in that string also? The To: field doesn't have "To:". EDIT: Aha. This web page says the From address looks ok. http://us2.php.net/manual/en/function.mail.php Link to comment https://forums.phpfreaks.com/topic/202098-blank-form-mail-send/#findComment-1060791 Share on other sites More sharing options...
tmayder Posted May 19, 2010 Author Share Posted May 19, 2010 kenrbnsn! I just knew it would be something too simple for me to figure it out on my own... geez! You were right, it was the case sensitive problem. THANK YOU!!! Problem solved!! bulrush, that's a great link, thanks to you too!! I will hang onto it! Cheers! Link to comment https://forums.phpfreaks.com/topic/202098-blank-form-mail-send/#findComment-1060805 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.