I can not seem to get this to work. It is saying that my curly bracket on line 2
ID: 646535 • Letter: I
Question
I can not seem to get this to work. It is saying that my curly bracket on line 23 is unexpected. I keep getting a parse error.
Here is the code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>assignment5-2</title>
</head>
<body class="twoColElsLtHdr">
<div id="header"><img src="Header.jpg" width="1127" height="354" alt="PHP Forms" /> </div>
<div id="feedback">
<h1 align="center">Feedback Page</h1>
<?php
function header_injectors($str){
return preg_match("[ ]/, $str");
}
if (isset($_POST["contact_submit"])){
$name = trim($_POST["name"]);
$email = trim($_POST["email"]);
$phone = $_POST["phone"];
$message = $_POST["comments"]
}
if (header_injectors($name) || header_injector($email)){
die();
}
if (!$name || !$email || !$phone ||!$message){
echo '<h2 class="error">Please retry your submission</h2><a href="feedback.php" class="button block">Please resubmit again.</a>';
exit;
}
$to="adamtdistefano@gmail.com";
$cc="";
$subject="DiStefano Feedback PHP Form";
$from= $email;
$message = "Name: $name ";
$message .= "Email: $email ";
$message .= "Phone: $phone ";
$message .= "Email: $message ";
$message=wordwrap($message, 72);
$headers = "MIME Version 1.0 ";
$headers .= "Content-type: text/plain; charset=iso-8859-1 ";
$headers .= "From: $name <$email> ";
$headers .= "X-Priority: 1 ";
$headers .= "X-MSMail-Priority: High ";
mail($to, $cc, $subject, $from, $message, $headers);
?>
<h3 align="center">We appreciate your feedback and look forward to seeing you again real soon!</h3>
<p><a href="/final">« Back to Home Page</a></p>
<?php } else { ?>
<form method="post" action="" id="Feedback">
<fieldset>
<h1 align="center">Please Fill Out the Form Below</h1>
<p align="center">
<label for ="name">Name:</label>
<input type="text" name="name" />
</p>
<p align="center">
<label for ="email">Email:</label>
<input type="text" name="email" />
</p>
<p align="center">
<label for ="phone">Phone:</label>
<input type="text" name="phone" />
</p>
<p align="center">Leave Your Feedback Below:</p>
<p align="center">
<textarea name="comments" cols="50" rows="10"></textarea>
</p>
<p align="center"><input name="submit" type="submit" value="Submit" />
<label>
<input type="reset" name="reset" id="reset" value="Reset" />
</label>
</p>
</fieldset>
</form>
<?php } ?>
<div id="footer"><p align="center"><a href="http://validator.w3.org/check?uri=referer"><img
src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a>
</p>
</div>
</div>
</body>
</html>
Explanation / Answer
All modern browsers have a build in XML parser that can be used to read an manipulate XML.
The parser reads XML into memory and converts into XML Dom object that can be accesses with java script.
PARSE Error:
Mainly parse error is syntax error
{} enclose code blocks, and syntax errors usually pertain to that. Curly braces are also used in variable variables and complex variable expressions (double quoted string context).
<p><a href="/final">« Back to Home Page</a></p><?php }
The above line has maintain closing brase then it gets the syntax error
Unexpected brace occured here then it removes directly
<p><a href="/final">«Back to Home Page </a></p><?php
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.