1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

I don't know how to fix this problem, email from.

Discussion in 'PHP' started by Jen-, Jan 10, 2007.

  1. #1
    Hi, I have a strange problem and don't know how to fix it, but it is very important to get it fixed, because the form won't send without it. For some reason the form won't send unless the form field "requesteremail" has data in it and I don't know why. So I thought if I just put an error command if the field was empty everything would work anyway, because people would be prompted to fill in the field. But when I add the "if empty" statement, for some reason it is also ignored, unless something is in the "requesteremail" field. I don't get it, it makes no sense to me, but I really need it fixed. Hope someone will help. Thank you very much.

     
    Jen-, Jan 10, 2007 IP
  2. proactive

    proactive Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    ya i will surely help you and i will give u new form if you want
     
    proactive, Jan 11, 2007 IP
  3. Jen-

    Jen- Peon

    Messages:
    151
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you very much, I don't need a new form, just need the part that is broken fixed.
     
    Jen-, Jan 11, 2007 IP
  4. adsblog

    adsblog Active Member

    Messages:
    659
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    70
    #4
    test it :
    if ($requesteremail == "" ) || ($requesterwebsite == "")) { echo " Error "; }
     
    adsblog, Jan 11, 2007 IP
  5. Jen-

    Jen- Peon

    Messages:
    151
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Drat I'm getting this on the just above, do you have more? Thanks.
    Parse error: parse error, unexpected T_BOOLEAN_OR
     
    Jen-, Jan 11, 2007 IP
  6. adsblog

    adsblog Active Member

    Messages:
    659
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    70
    #6
    if ((empty($requesteremail)) || (empty($requesterwebsite))) {echo "field empty please try again";}

    if ( ( 1 = 1 ) || (2 = 2 ) ) { echo "done"; }
    check it .
     
    adsblog, Jan 12, 2007 IP
  7. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #7
    If requester email isn't set then the headers will be incorrect which is why the email is never sent, try either

    if(!$_POST['requesteremail'])
    {
    echo "We NEED a requester email");
    exit;
    }

    before the form is processed

    or

    if(!$_POST['requesteremail'])
    {
    $requesteremail = "def@dom.com";
    }

    after the $requesteremail = $_POST['requesteremail']; line.

    or

    
    ?>
    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>
    <input type="text" name="page" size=20>
    <input type="submit" name="submit" value="Submit" /></form>
    <?php 
    }
    else
    {
     	if(!$_POST['requesteremail'] or !ereg("^[^@]{1,64}@[^@]{1,255}$", $_POST['requesteremail']))
     	{
    		echo "Please enter a valid email address.";
    		exit;
    	}
    	$mailto = 'emailaddress@something.com' ; 
    	$subject = "Subject of email" ;
    	$websitename = stripslashes(trim($_POST['websitename'])) ; 
    	$requesteremail = stripslashes(trim($_POST['requesteremail'])) ; 
    	$page = stripslashes(trim($_POST['page'])) ; 
    	$messageproper = "$websitename\n" . 
    					 "$requestermail\n" . 
    					 "$page\n";
    	$com = @mail
        (
    	$mailto, $subject, nl2br($messageproper), 
    	"From: \"$requesteremail\" <$requesteremail>\n" . 
    	"Reply-To: \"$requesteremail\" <$requesteremail>\n" .
    	"Content-Type: text/html\n"
        )
    	if($com)
    	{
    		echo "Mail sent.";	
    	}
    	else
    	{
    		echo "Mail NOT sent";
    	}
    }}}//these 3 brackets needed from other mysql variables earlier.
    ?> 
    
    PHP:
    Might work, untested, but something along those lines....
     
    krakjoe, Jan 13, 2007 IP
  8. [*-AnOnYmOuS-*]

    [*-AnOnYmOuS-*] Active Member

    Messages:
    253
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #8
    im guessing you could also add a default value so its somthing like "not @mentioned.com"
     
    [*-AnOnYmOuS-*], Jan 13, 2007 IP
  9. Jen-

    Jen- Peon

    Messages:
    151
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    krak I'm trying to use your last one but it says it doesn't like this. unexpected "T_IF "

    if($com) {echo "Mail sent."; } else { echo "Mail NOT sent";}
    which is really good considering it was all untested.

    All the others didn't work and of adsblog too. Which seems odd to me. For instance this one.

    if(!$_POST['requesteremail'])
    {
    echo "We NEED a requester email");
    exit;
    }
    How can I have it execute before the form is processed? Right now it seems to be checking the email header value first and then checking for the echo's last. Shouldn't it check the ifs and echo's before trying to send the email? Please give me your expert opinions on this. Thanks.
     
    Jen-, Jan 14, 2007 IP
  10. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #10
    sry

    replace

    
    $com = @mail
        (
        $mailto, $subject, nl2br($messageproper), 
        "From: \"$requesteremail\" <$requesteremail>\n" . 
        "Reply-To: \"$requesteremail\" <$requesteremail>\n" .
        "Content-Type: text/html\n"
        )
    
    PHP:
    with

    
    $com = @mail
        (
        $mailto, $subject, nl2br($messageproper), 
        "From: \"$requesteremail\" <$requesteremail>\n" . 
        "Reply-To: \"$requesteremail\" <$requesteremail>\n" .
        "Content-Type: text/html\n"
        );
    
    PHP:
    Give that a whirl
     
    krakjoe, Jan 16, 2007 IP