I am very new to the world of PHP and am trying to have an auto-email form. The form directs to the correct page (feedback.php) but when it does this I get an error messagr reading Parse error: parse error in /home/virtual/site52/fst/var/www/html/feedback.php on line 38 Here is a part of the PHP code I am using.
$company = $_POST['company'] ;
$http_referrer = getenv( "HTTP_REFERER" );
if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($name)|| empty($email)|| empty($company)) {
header( "Location: $errorurl" );
exit ;
}
if (get_magic_quotes_gpc()) {
$Feedback = stripslashes( $Feeback );
}
$messageproper =
"This message was sent from:\n" .
"$http_referrer\n" .
"------------------------- COMMENTS -------------------------\n\n" .
$comments .
"\n\n------------------------------------------------------------\n" ;
So, my question is what am I doing wrong, and how can I fix it?
Thanks in advance for any help!:rocker:moved this into the PHP sub-forum here so that you can get an answer to your question more efficiently than sitting out in the general Server-Side forum.
Hope the fellas in here can get ya going ok, which line is 38?Sorry, that is probably the most important information. LOL. Line 38 including empty lines (no characters on the lines) is $company = $_POST['company'] ; Line 38 not including empty lines is "\n\n------------------------------------------------------------\n" ;
Thanks again for any help!What are the lines of code immediately before this:
$company = $_POST['company'] ;
Are you missing a semicolon ( ; ) on the line of code immediately before that one?BoeingDrew - line numbers include the empty lines.
also, the problem in the code may actually come from a typo in a previous line, so knowing what preceded line 38 would be helpful.
finally, is this the whole error message:
Parse error: parse error in /home/virtual/site52/fst/var/www/html/feedback.php on line 38
as there is usually a better clue as to what the error is - something "unexpected SOMETHING expecting SOMETHING_ELSE".Thanks all for the help, it looks as if I was missing a semi-colon. Anyway, another problem has arisen. The email sends but there is nothing in the body of the email that sends. Also, when the page is redirected to the feedback.php page it shows an error message reading...
The page cannot be found
The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.
HTTP 404 - File not found
Internet Explorer
Any ideas one what the problem could be?
Again all responses are appreciated!well, at first guess the page you are trying to open doesn't exist
check that the action of your form is correct.
as for the email - have you checked that there is anything in the variable being passed to the mail() function as the message?
just echo the message variable onto the brower screen...Thanks for all your help! It seems to have fixed that problem, but now I have another problem with my code! I am now getting the error message reading...
Parse error: parse error in /home/virtual/site52/fst/var/www/html/feedback.php on line 69
Of course there has to be a twist, right? Well, there is...it is that there is no line 69! Here is the last few lines of the code, with the last line, ?> , being line number 65.
mail($mailto, $subject, $messageproper, "From: \"$email\" <$email>\nReply-To: \"$email\" <$email>\nX-Mailer: chfeedback.php 2.02" );
header( "Location: $thankyouurl" );
exit;
?>
I am completly stumped! Any ideas on what needs to be added/changed?
Thanks for any help!is that all the output in your browser?
usually there is more information about the error, which would be useful.
it may be that you have a few empty lines after line 65.
you also might have not put enough } braces and it is complaining about that.
check for everytime you use a { there is a corresponding }
(ps - php parser would usually output an "EXPECTING T_END" or something like that on the above error).That was all the error message read. I have fixed the problem, actually another user did. Now, my problem is that there is no email being sent. Also, the error.html page shows up no matter what! Here is the code...
<?
// ------------- CONFIGURABLE SECTION ------------------------
// $mailto - set to the email address you want the form
// sent to, eg
//$mailto= "[email protected]" ;
$mailto = <!-- e --><a href="mailto:'[email protected]">'[email protected]</a><!-- e -->' ;
// $subject - set to the Subject line of the email, eg
//$subject= "Feedback Form" ;
$subject = "Form" ;
// the pages to be displayed, eg
//$formurl= "http://www.example.com/feedback.html" ;
//$errorurl= "http://www.example.com/error.html" ;
//$thankyouurl= "http://www.example.com/thankyou.html" ;
$formurl = "http://www.website.com/search.html" ;
$errorurl = "http://www.website.com/error.html" ;
$thankyouurl = "http://www.website.com/done.html" ;
// -------------------- END OF CONFIGURABLE SECTION ---------------
$Departure_airport = $_POST['Departure_airport'] ;
$Departure_airport = $_POST['Arrival_airport'] ;
$Departure_month = $_POST['Departure_month'] ;
$Departure_day = $_POST['Departure_day'] ;
$Arrival_month = $_POST['Return_month'] ;
$Arrival_day = $_POST['Return_day'] ;
$Class = $_POST['Class'] ;
$passengers = $_POST['passengers'] ;
$email = $_POST['email'] ;
$company = $_POST['company'] ;
$http_referrer = getenv( "http://www.website.com" );
if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit;
}
if (empty($name)|| empty($email)|| empty($company)) {
header( "Location: $errorurl" );
exit;
}
"------------------------- COMMENTS -------------------------\n\n" .
$comments .
"\n\n------------------------------------------------------------\n" ;
mail($mailto, $subject, $messageproper, "From: \"$email\" <$email>\nReply-To: \"$email\" <$email>\nX-Mailer: chfeedback.php 2.02" );
header( "Location: $thankyouurl" );
exit;
?>
Thanks for any help!what does your form look like?HTML form looks like this...
<FORM action="feedback.php" method="post">
<TABLE border="0" cellpadding="8" cellspacing="8" summary="Travel Search">Departure Airport:
<INPUT type="text" name="Departure_airport" size="12" /><BR>Arrival Airport:
<INPUT type="text" name="Arrival_airport" size="12" /><BR><BR>Departure Date
<SELECT name="Departure_month" size="1">
<OPTION selected>August
<OPTION>September
<OPTION>October
<OPTION>November
<OPTION>December
<OPTION>January
<OPTION>Febuary
<OPTION>March
<OPTION>April
<OPTION>May
<OPTION>June
<OPTION>July
</SELECT>
<SELECT name="Departure_day" size="1">
<OPTION selected>1
<OPTION>2
<OPTION>3
<OPTION>4
<OPTION>5
<OPTION>6
<OPTION>7
<OPTION>8
<OPTION>9
<OPTION>10
<OPTION>11
<OPTION>12
<OPTION>13
<OPTION>14
<OPTION>15
<OPTION>16
<OPTION>17
<OPTION>18
<OPTION>19
<OPTION>20
<OPTION>21
<OPTION>22
<OPTION>23
<OPTION>24
<OPTION>25
<OPTION>26
<OPTION>27
<OPTION>28
<OPTION>29
<OPTION>30
<OPTION>31
</SELECT><BR>Return Date
<SELECT name="Return_month" size="1">
<OPTION selected>August
<OPTION>September
<OPTION>October
<OPTION>November
<OPTION>December
<OPTION>January
<OPTION>Febuary
<OPTION>March
<OPTION>April
<OPTION>May
<OPTION>June
<OPTION>July
</SELECT>
<SELECT name="Return_day" size="1">
<OPTION selected>1
<OPTION>2
<OPTION>3
<OPTION>4
<OPTION>5
<OPTION>6
<OPTION>7
<OPTION>8
<OPTION>9
<OPTION>10
<OPTION>11
<OPTION>12
<OPTION>13
<OPTION>14
<OPTION>15
<OPTION>16
<OPTION>17
<OPTION>18
<OPTION>19
<OPTION>20
<OPTION>21
<OPTION>22
<OPTION>23
<OPTION>24
<OPTION>25
<OPTION>26
<OPTION>27
<OPTION>28
<OPTION>29
<OPTION>30
<OPTION>31
</SELECT><BR><BR>Class of Service:
<SELECT name="Class" size="1">
<OPTION selected>Coach
<OPTION>Business
<OPTION>First
</SELECT><BR>Number of Passengers:
<INPUT type="text" name="passengers" size="2" /><BR><BR>Email Address:
<INPUT type="text" name="email" size="25" /><BR>Company Name:
<INPUT type="text" name="company" size="25" />
<TR>
<TD align="center" colspan="2">
<INPUT type="submit" value="Search" />
<INPUT type="reset" value="Reset All Fields" /><BR/>
</TD>
</TR>
</TABLE>
</FORM>you don't have a variable in the form for
$name
it will always fail on that cause it doesn't exist.
also you have to have values in your option tags. if you don't it will be empty as well.Thanks to everyone for your help! All is working great now.:rocker:
$company = $_POST['company'] ;
$http_referrer = getenv( "HTTP_REFERER" );
if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($name)|| empty($email)|| empty($company)) {
header( "Location: $errorurl" );
exit ;
}
if (get_magic_quotes_gpc()) {
$Feedback = stripslashes( $Feeback );
}
$messageproper =
"This message was sent from:\n" .
"$http_referrer\n" .
"------------------------- COMMENTS -------------------------\n\n" .
$comments .
"\n\n------------------------------------------------------------\n" ;
So, my question is what am I doing wrong, and how can I fix it?
Thanks in advance for any help!:rocker:moved this into the PHP sub-forum here so that you can get an answer to your question more efficiently than sitting out in the general Server-Side forum.
Hope the fellas in here can get ya going ok, which line is 38?Sorry, that is probably the most important information. LOL. Line 38 including empty lines (no characters on the lines) is $company = $_POST['company'] ; Line 38 not including empty lines is "\n\n------------------------------------------------------------\n" ;
Thanks again for any help!What are the lines of code immediately before this:
$company = $_POST['company'] ;
Are you missing a semicolon ( ; ) on the line of code immediately before that one?BoeingDrew - line numbers include the empty lines.
also, the problem in the code may actually come from a typo in a previous line, so knowing what preceded line 38 would be helpful.
finally, is this the whole error message:
Parse error: parse error in /home/virtual/site52/fst/var/www/html/feedback.php on line 38
as there is usually a better clue as to what the error is - something "unexpected SOMETHING expecting SOMETHING_ELSE".Thanks all for the help, it looks as if I was missing a semi-colon. Anyway, another problem has arisen. The email sends but there is nothing in the body of the email that sends. Also, when the page is redirected to the feedback.php page it shows an error message reading...
The page cannot be found
The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.
HTTP 404 - File not found
Internet Explorer
Any ideas one what the problem could be?
Again all responses are appreciated!well, at first guess the page you are trying to open doesn't exist
check that the action of your form is correct.
as for the email - have you checked that there is anything in the variable being passed to the mail() function as the message?
just echo the message variable onto the brower screen...Thanks for all your help! It seems to have fixed that problem, but now I have another problem with my code! I am now getting the error message reading...
Parse error: parse error in /home/virtual/site52/fst/var/www/html/feedback.php on line 69
Of course there has to be a twist, right? Well, there is...it is that there is no line 69! Here is the last few lines of the code, with the last line, ?> , being line number 65.
mail($mailto, $subject, $messageproper, "From: \"$email\" <$email>\nReply-To: \"$email\" <$email>\nX-Mailer: chfeedback.php 2.02" );
header( "Location: $thankyouurl" );
exit;
?>
I am completly stumped! Any ideas on what needs to be added/changed?
Thanks for any help!is that all the output in your browser?
usually there is more information about the error, which would be useful.
it may be that you have a few empty lines after line 65.
you also might have not put enough } braces and it is complaining about that.
check for everytime you use a { there is a corresponding }
(ps - php parser would usually output an "EXPECTING T_END" or something like that on the above error).That was all the error message read. I have fixed the problem, actually another user did. Now, my problem is that there is no email being sent. Also, the error.html page shows up no matter what! Here is the code...
<?
// ------------- CONFIGURABLE SECTION ------------------------
// $mailto - set to the email address you want the form
// sent to, eg
//$mailto= "[email protected]" ;
$mailto = <!-- e --><a href="mailto:'[email protected]">'[email protected]</a><!-- e -->' ;
// $subject - set to the Subject line of the email, eg
//$subject= "Feedback Form" ;
$subject = "Form" ;
// the pages to be displayed, eg
//$formurl= "http://www.example.com/feedback.html" ;
//$errorurl= "http://www.example.com/error.html" ;
//$thankyouurl= "http://www.example.com/thankyou.html" ;
$formurl = "http://www.website.com/search.html" ;
$errorurl = "http://www.website.com/error.html" ;
$thankyouurl = "http://www.website.com/done.html" ;
// -------------------- END OF CONFIGURABLE SECTION ---------------
$Departure_airport = $_POST['Departure_airport'] ;
$Departure_airport = $_POST['Arrival_airport'] ;
$Departure_month = $_POST['Departure_month'] ;
$Departure_day = $_POST['Departure_day'] ;
$Arrival_month = $_POST['Return_month'] ;
$Arrival_day = $_POST['Return_day'] ;
$Class = $_POST['Class'] ;
$passengers = $_POST['passengers'] ;
$email = $_POST['email'] ;
$company = $_POST['company'] ;
$http_referrer = getenv( "http://www.website.com" );
if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit;
}
if (empty($name)|| empty($email)|| empty($company)) {
header( "Location: $errorurl" );
exit;
}
"------------------------- COMMENTS -------------------------\n\n" .
$comments .
"\n\n------------------------------------------------------------\n" ;
mail($mailto, $subject, $messageproper, "From: \"$email\" <$email>\nReply-To: \"$email\" <$email>\nX-Mailer: chfeedback.php 2.02" );
header( "Location: $thankyouurl" );
exit;
?>
Thanks for any help!what does your form look like?HTML form looks like this...
<FORM action="feedback.php" method="post">
<TABLE border="0" cellpadding="8" cellspacing="8" summary="Travel Search">Departure Airport:
<INPUT type="text" name="Departure_airport" size="12" /><BR>Arrival Airport:
<INPUT type="text" name="Arrival_airport" size="12" /><BR><BR>Departure Date
<SELECT name="Departure_month" size="1">
<OPTION selected>August
<OPTION>September
<OPTION>October
<OPTION>November
<OPTION>December
<OPTION>January
<OPTION>Febuary
<OPTION>March
<OPTION>April
<OPTION>May
<OPTION>June
<OPTION>July
</SELECT>
<SELECT name="Departure_day" size="1">
<OPTION selected>1
<OPTION>2
<OPTION>3
<OPTION>4
<OPTION>5
<OPTION>6
<OPTION>7
<OPTION>8
<OPTION>9
<OPTION>10
<OPTION>11
<OPTION>12
<OPTION>13
<OPTION>14
<OPTION>15
<OPTION>16
<OPTION>17
<OPTION>18
<OPTION>19
<OPTION>20
<OPTION>21
<OPTION>22
<OPTION>23
<OPTION>24
<OPTION>25
<OPTION>26
<OPTION>27
<OPTION>28
<OPTION>29
<OPTION>30
<OPTION>31
</SELECT><BR>Return Date
<SELECT name="Return_month" size="1">
<OPTION selected>August
<OPTION>September
<OPTION>October
<OPTION>November
<OPTION>December
<OPTION>January
<OPTION>Febuary
<OPTION>March
<OPTION>April
<OPTION>May
<OPTION>June
<OPTION>July
</SELECT>
<SELECT name="Return_day" size="1">
<OPTION selected>1
<OPTION>2
<OPTION>3
<OPTION>4
<OPTION>5
<OPTION>6
<OPTION>7
<OPTION>8
<OPTION>9
<OPTION>10
<OPTION>11
<OPTION>12
<OPTION>13
<OPTION>14
<OPTION>15
<OPTION>16
<OPTION>17
<OPTION>18
<OPTION>19
<OPTION>20
<OPTION>21
<OPTION>22
<OPTION>23
<OPTION>24
<OPTION>25
<OPTION>26
<OPTION>27
<OPTION>28
<OPTION>29
<OPTION>30
<OPTION>31
</SELECT><BR><BR>Class of Service:
<SELECT name="Class" size="1">
<OPTION selected>Coach
<OPTION>Business
<OPTION>First
</SELECT><BR>Number of Passengers:
<INPUT type="text" name="passengers" size="2" /><BR><BR>Email Address:
<INPUT type="text" name="email" size="25" /><BR>Company Name:
<INPUT type="text" name="company" size="25" />
<TR>
<TD align="center" colspan="2">
<INPUT type="submit" value="Search" />
<INPUT type="reset" value="Reset All Fields" /><BR/>
</TD>
</TR>
</TABLE>
</FORM>you don't have a variable in the form for
$name
it will always fail on that cause it doesn't exist.
also you have to have values in your option tags. if you don't it will be empty as well.Thanks to everyone for your help! All is working great now.:rocker: