11Tami Posted January 10, 2007 Share Posted January 10, 2007 Hello, I need help. I can't figure out why entering something in the form field "requesteremail" sends the email, but if it is empty, none of the fields will send to the email. I don't see anything in here that would cause this to happen. Please let me know why this is happening, thank you very much.[code]while ($row = mysql_fetch_array($result)){ if ($_POST['websitename']==""){?><form method="post" action="<?php $_SERVER['PHP_SELF'] ;?>"><input type="hidden" value="<?php echo $row[websitename];?>" name="websitename"><input type="text" name="requesteremail" size=20><br /><br /><input type="text" name="requesterwebsite" size=20><br /><br /><input type="text" name="page" size=20><br /><br /><input type="submit" name="submit" value="Submit" /></form><?php }else{$mailto = '[email protected]' ; $subject = "Subject of email" ;$requesteremail = $_POST['requesteremail'] ; $requesterwebsite = $_POST['requesterwebsite'] ;$reciprocalpage = $_POST['page'] ; $uself = 0;$sep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;$messageproper = "$requesteremail\n" . "$requesterwebsite\n" . "$page\n";mail($mailto, $subject, $messageproper, "From: \"$requesterwebsite\" <$requesteremail>" . $sep . "Reply-To: \"$requesterwebsite\" <$requesteremail>" . $sep);echo "email sent"; }}}//these 3 brackets needed from other mysql variables earlier.?> [/code] Quote Link to comment https://forums.phpfreaks.com/topic/33569-why-one-field-only-sends-the-email/ Share on other sites More sharing options...
genericnumber1 Posted January 10, 2007 Share Posted January 10, 2007 The email may be being sent it's just that your spam filter may be blocking the email because it has no sender email address...try changing[code=php:0]$requesteremail = $_POST['requesteremail'] ; [/code]to[code=php:0]$requesteremail = (!empty($_POST['requesteremail'])) ? $_POST['requesteremail'] : '[email protected]'; [/code]it's just an email that's being set if $_POST['requesteremail'] isn't... if I totally missed your problem then be sure to tell me! and I'll be sure to blame it on it being 4:40 AM Quote Link to comment https://forums.phpfreaks.com/topic/33569-why-one-field-only-sends-the-email/#findComment-157224 Share on other sites More sharing options...
11Tami Posted January 11, 2007 Author Share Posted January 11, 2007 I think people are having trouble reading my code, its so small when I surround it with the code tags so here it is without it. generic number, I don't understand what this will do attached to it '[email protected]'; once I know that I'll know how to try it.Also, it isn't haveing any trouble reading requesteremail, its just not reading the other form fields but I'll try it anyway. So anyone else with other suggestions please let me know. Thanks!while ($row = mysql_fetch_array($result)){ if ($_POST['websitename']==""){?><form method="post" action="<?php $_SERVER['PHP_SELF'] ;?>"><input type="hidden" value="<?php echo $row[websitename];?>" name="websitename"><input type="text" name="requesteremail" size=20><br /><br /><input type="text" name="requesterwebsite" size=20><br /><br /><input type="text" name="page" size=20><br /><br /><input type="submit" name="submit" value="Submit" /></form><?php }else{$mailto = '[email protected]' ; $subject = "Subject of email" ;$requesteremail = $_POST['requesteremail'] ; $requesterwebsite = $_POST['requesterwebsite'] ;$reciprocalpage = $_POST['page'] ; $uself = 0;$sep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;$messageproper = "$requesteremail\n" . "$requesterwebsite\n" . "$page\n";mail($mailto, $subject, $messageproper, "From: \"$requesterwebsite\" <$requesteremail>" . $sep . "Reply-To: \"$requesterwebsite\" <$requesteremail>" . $sep);echo "email sent"; }}}//these 3 brackets needed from other mysql variables earlier.?> Quote Link to comment https://forums.phpfreaks.com/topic/33569-why-one-field-only-sends-the-email/#findComment-157868 Share on other sites More sharing options...
11Tami Posted January 11, 2007 Author Share Posted January 11, 2007 $requesteremail = (!empty($_POST['requesteremail'])) ? $_POST['requesteremail'] : '[email protected]'; I tried this with and without the last field and with a real email address in the last field. It doesn't help. The problem I am having is the form only sends when there is something in this form field. "requesteremail" <input type="text" name="requesteremail" size=20>Can someone help tell me how to fix it? Thank you very much. Quote Link to comment https://forums.phpfreaks.com/topic/33569-why-one-field-only-sends-the-email/#findComment-157881 Share on other sites More sharing options...
Jessica Posted January 11, 2007 Share Posted January 11, 2007 You'll need a default from. $requesteremail = $_POST['requesteremail'] ; if(!$requesteremail){ $requesteremail = 'default';} Quote Link to comment https://forums.phpfreaks.com/topic/33569-why-one-field-only-sends-the-email/#findComment-157883 Share on other sites More sharing options...
11Tami Posted January 11, 2007 Author Share Posted January 11, 2007 Can you please tell me why a default both of you are giving me is supposed to help? I tried that as well with no luck.I also tried thisif (empty($requesteremail) || empty($requesterwebsite)) {echo "field empty please try again";}else {echo "email sent!";}So that if some of the other fields as well as requesteremail are not filled in they will go back to fill it in. But again if requesterwebsite is filled in but requesteremail is not, the echo "field is empty" won't even appear. If someone can tell me why the email isn't reading the "from" field it help me to know the right questions to ask. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/33569-why-one-field-only-sends-the-email/#findComment-157919 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.