Jump to content

Blank form mail send


tmayder

Recommended Posts

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

$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

 

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.