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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Php error (pharse and more)

Status
Not open for further replies.

ian1969

Programmer
Joined
Nov 22, 2002
Messages
2
Location
ES
This is my code which I get the error:
Parse error: parse error, unexpected '{' in etc..etc Line 24

Line 24 is: (mail($email,$subject,$from,$message)) {
If I add elseif to the above line I get unexpected elseif for the above line

If I then do this:

\\ REMOVE THIS LINE $message = "\nFirst Name: ".$full_name;
elseif(mail($email,$subject,$from,$message,$full_name)) {

I get the message, but with NO full_name data!

Also how can I add extra fields it tells me you can only have 5!

<?php


$email = 'information@mywebsite.com';
$subject = $HTTP_POST_VARS['subject'];
$message = $HTTP_POST_VARS['message'];
$from = $HTTP_POST_VARS['from'];
$full_name = $HTTP_POST_VARS['full_name'];
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $from)) {
echo "<h4>Invalid email address, please check and try again</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
} elseif ($full_name == "") {
echo "<h4>Sorry you have not entered your name</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
}
elseif ($message == "") {
echo "<h4>You have not entered a message - please return and try again</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
}
$message = "\nFirst Name: ".$full_name;
(mail($email,$subject,$from,$message)) {
echo "<h4>Your email has been sent, we will reply as soon as possible.</h4>";
echo "<h4>Regards. </h4>";
echo "<h4>Ian & Lynn</h4>";
echo "<h4></h4>";
echo "<h4></h4>";
echo "<a href='javascript:window.close();'>Close window</a>";
} else {
echo "<h4>Cannot send email please try again later or send a email to: $email </h4>";
echo "<h4>Regards. </h4>";
echo "<h4>Ian & Lynn</h4>";
echo "<h4></h4>";
echo "<h4></h4>";
echo "<a href='javascript:window.close();'>Close window</a>";
}
?>
 
(mail($email,$subject,$from,$message))

shouldn't this be
mail($email,$subject,$from,$message);

:-)

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
OK I managed it (WELL ALMOST) The code now works but I can't get it to error checking to work or confirmation message to appear.

I've // out the bits that stopping it from working at the bottom, also the error checking in the middle isn't working.

How can I get the confirmation message ec to work?

Ian

<?php

$email = 'reservations@mywebsite.com';
$subject = $HTTP_POST_VARS['subject'];
$message = $HTTP_POST_VARS['message'];
$from = $HTTP_POST_VARS['from']; //persons email address
$name = $HTTP_POST_VARS['name'];
$arrival_day = $HTTP_POST_VARS['arrival_day'];
$arrival_month = $HTTP_POST_VARS['arrival_month'];
$arrival_year = $HTTP_POST_VARS['arrival_year'];
$departure_day = $HTTP_POST_VARS['departure_day'];
$departure_month = $HTTP_POST_VARS['departure_month'];
$departure_year = $HTTP_POST_VARS['departure_year'];

if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $from)) {
echo "<h4>Invalid email address, please check and try again</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
} elseif ($name == "") {
echo "<h4>Sorry you have not entered your name</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
}
elseif ($message == "") {
echo "<h4>You have not entered a message - please return and try again</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
}

$message = "Additional Requests: ".$message;
$message .= "\n\nEmail Address: ".$from;
$message .= "\nName: ".$name;
$message .= "\n\nArrival Day: ".$arrival_day;
$message .= "\nArrival Month: ".$arrival_month;
$message .= "\nArrival Year: ".$arrival_year;
$message .= "\n\nDeparture Day: ".$departure_day;
$message .= "\nDeparture Month: ".$departure_month;
$message .= "\nDeparture Year: ".$departure_year;

(mail($email, $subject, $message))
//echo "<h4>Your reservation request has been sent, we will confirm back to you as soon as possible.</h4>";
//echo "<h4>Regards. </h4>";
//echo "<h4>Ian & Lynn</h4>";
//echo "<h4></h4>";
//echo "<h4></h4>";
//echo "<a href='javascript:window.close();'>Close window</a>";

//else {
// echo "<h4>Cannot send email please try again later or send a email to: $email </h4>";
// echo "<h4>Regards. </h4>";
// echo "<h4>Ian & Lynn</h4>";
// echo "<h4></h4>";
// echo "<h4></h4>";
// echo "<a href='javascript:window.close();'>Close window</a>";
//}
?>
 
Code:
[COLOR=red]if[/color](mail($email, $subject, $message))[COLOR=red]{[/color]
  echo "<h4>Your reservation request has been sent, we will confirm back to you as soon as possible.</h4>";
  echo "<h4>Regards. </h4>";
  echo "<h4>Ian & Lynn</h4>";
  echo "<h4></h4>";
  echo "<h4></h4>";
  echo "<a href='javascript:window.close();'>Close window</a>";
   
[COLOR=red]}[/color] else {
  echo "<h4>Cannot send email please try again later or send a email to: $email </h4>";
  echo "<h4>Regards. </h4>";
  echo "<h4>Ian & Lynn</h4>";
  echo "<h4></h4>";
  echo "<h4></h4>";
  echo "<a href='javascript:window.close();'>Close window</a>";
}

There is a missing if statament and curly braces. Above should work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top