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.
Drat I'm getting this on the just above, do you have more? Thanks. Parse error: parse error, unexpected T_BOOLEAN_OR
if ((empty($requesteremail)) || (empty($requesterwebsite))) {echo "field empty please try again";} if ( ( 1 = 1 ) || (2 = 2 ) ) { echo "done"; } check it .
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....
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.
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