Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A quasi autoresponder 1

Status
Not open for further replies.

EvilAsh

Technical User
Joined
Oct 22, 2005
Messages
56
Location
GB
Hi there.

I have built a basic html form with php mail handling and it works pretty well.

However, I was getting cocky and tried to create a quasi autoresponder and now the trouble has started!!

I have extended the mail() statement like so:

Code:
elseif (mail($my_email,$subject,$message,'From: '.$email."\r\n"))&&(mail($email,$subject,$message,'From: '.$my_email."\r\n"))

Previously it read:
Code:
elseif (mail($my_email,$subject,$message,'From: '.$email."\r\n"))
and worked fine.

The error I am getting reads:

Parse error: parse error, unexpected T_BOOLEAN_AND in /home/websimpleuk/public_html/new/mail.php on line 79.

I have Googled the problem to no avail. Can you help please??

The full code is:

Code:
					<?php
$my_email = "info@websimple.co.uk";
/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
$email = $HTTP_POST_VARS['email'];
$name = $HTTP_POST_VARS['name'];
$company = $HTTP_POST_VARS['company'];
$subject = $HTTP_POST_VARS['subject'];

$comments = $HTTP_POST_VARS['comments'];

$message   = "Name: $name \n";
$message   .= "E-mail: $email \n";
$message  .= "Company: $company \n";
$message  .= "Comments: $comments \n\n";



if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
  echo "<blockquote> <p>Sorry, the e-mail address you gave was invalid. Please re-enter email address.</p></blockquote> ";
  echo "<blockquote><a href='javascript:history.back(1);'class='blackfoot'>Return to form.</a></blockquote> ";
} elseif ($message == "") {
  echo "<blockquote> <p>Sorry, you have not left a message. Please add a message.</p></blockquote> ";
  echo "<blockquote><a href='javascript:history.back(1);' class='blackfoot'>Return to form.</a></blockquote> ";
}

/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */
elseif (mail($my_email,$subject,$message,'From: '.$email."\r\n")) && (mail($email,$subject,$message,'From: '.$my_email."\r\n")){
  echo "<blockquote> <p>Thank you for your interest. We will repond as soon as possible</p></blockquote> ";
} else {
  echo "<blockquote><p>Sorry but due to an unforseen error we cannot send email to $email. <br><br>Please send your enquiry to info@websimple.co.uk using your usual e-mail application.</p></blockquote> ";
}
?>
 
Part of your condition is outside of the elseif's parentheses:

Code:
elseif
[red]([/red]
	mail
	(
		$my_email,
		$subject,
		$message,
		'From: '.$email."\r\n"
	)
[red])[/red]
&&
(
	mail
	(
		$email,
		$subject,
		$message,
		'From: '.$my_email."\r\n"
	)
)

The parentheses in red are the ones that limit the condition to be used by the elseif.



Want the best answers? Ask the best questions! TANSTAAFL!
 
Doh! Schoolboy error.

Thanks for the quick response.

Regards.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top