Jump to content

Why one field only sends the email.


11Tami

Recommended Posts

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 = 'emailaddress@something.com' ;
$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]
Link to comment
Share on other sites

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'] : 'AnotherEmail@hotmail.com';
[/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
Link to comment
Share on other sites

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  'AnotherEmail@hotmail.com'; 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 = 'emailaddress@something.com' ;
$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.
?>
Link to comment
Share on other sites

$requesteremail = (!empty($_POST['requesteremail'])) ? $_POST['requesteremail'] : 'AnotherEmail@hotmail.com';

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.

Link to comment
Share on other sites

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 this
if (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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.