this question has answer here:
- php parse/syntax errors; , how solve them? 12 answers
for reason keep getting error within backend code contact form
here contact form
<div id = "form"> <form action ="contact2.php" method="post"> hi rebekah name <br> <input type="text" name="name"> <br> email <br> <input type="text" name="email"> <br> message <br> <textarea name="message" rows=6 cols=40> </textarea> <br> <input type="submit" value="submit"> <?php include "contact2.php"; echo $result; ?> </div>
here backend php code
<?php $field_name = $_post['name']; $email = $_post['email']; $field_message = $_post['message']; $mail_to = 'rebekahshaw92@yahoo.co.uk'; $subject = 'message site visitor ' . $field_name; $body_message = 'from: '.$field_name."\n"; $body_message .= 'e-mail: '.$email."\n"; $body_message .= 'message: '.$field_message; $headers = "from: $email\r\n"; $headers .= "reply-to: $email\r\n"; $mail_status = mail($mail_to, $subject, $body_message, $headers); // check if name has been entered if (!$_post['name']) { $field_name = 'please enter name'; } // check if email has been entered , valid if (!$_post['email'] || !filter_var($_post['email'], filter_validate_email)) { $email = 'please enter valid email address'; } //check if message has been entered if (!$_post['message']) { $field_message = 'please enter message'; } // if there no errors, send email if (!$field_name && !$email && !$field_message) { if (mail ($_to, $subject, $body_message, $headers)) { $result='<div class="alert alert-success">thank you! in touch</div>'; } else { $result='<div class="alert alert-danger">sorry there error sending message. please try again later</div>'; } ?>
when run code there said error in php code on line 43 last line can't seem see problem losing tag php code, when take closing php tag out still same message.
here message displayed.
parse error: syntax error, unexpected end of file in d:\contact2.php on line 43
i have taken out file found above safety reasons.
you missing closing tag of if
statement.
add }
before closing tag ?>
on last line.
Comments
Post a Comment