Error: Special Characters Must Be Escaped
Hello. I'm attempting to put php code (for the first time) in an html document. I'm getting a "Special Characters Must be Escaped" error at the opening and closing tags of the php code. I'll post all the code I'm using but the php code will eventually be placed in a separate document for the form element to action to. Any help would be greatly appreciated.
<!DOCTYPE HTML>
<html>
<body>
<form name="photosubmission form" action="photoform-to-email.php"
<form name="photosubmissionform" action="photoform-to-email.php>
<label for="fname">First Name:</label><br>
<input type="text" id="fname" name="fname" placeholder="John" required><br>
<label for="lname">Last Name:</label><br>
<input type="text" id="lname" name="lname" placeholder="Doe" required><br>
<label for="phone">Phone Number:</label><br>
<input type="tel" id="phone" name="phone" class="phone" placeholder="123.456.7890" pattern="[0-9]{3}.[0-9]{3}.[0-9]{4}"><br>
<label for="email">Email:</label><br>
<input type="email" id="email" name="email" class="email" placeholder="johndoe@gmail.com" required><br>
<label for="image">Image File</label><br>
<input type="file" id="image" name="image" multiple>
<input type="submit" value="Submit">
</form>
</body>
</html>
<?php
if(!isset{$_POST['submit']))
{
echo "Error! You need to submit the form!";
}
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$file = $_POST['file'];
if(empty($fname) || empty($lname))
{ echo "Please enter your full name.";
exit;
}
if(empty($email))
{ echo "Please enter a valid email address.";
exit;
}
$email_from = 'marketing@cittrucks.com';
$email_subject = "New Photo Contest Submission";
$email_body = "You have received a new submission from $name. \n".
"email address: $visitor_email\n".
"Here is the submission: \n $message".
$to = "marketing@cittrucks.com";
$headers = "From: $email_from \r\n";
mail($to,$email_subject,$email_body,$headers);
function IsInjected($str)
{
$injections = array('(\n+);,
'(\r+)',
'(\t+)',
'(%0A+)',
'(%08+)',
'(%09+)'
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str))
{return true;
}
else
{return false;
}
if(IsInjected($email))
{
echo "Please enter a valid email address.";
exit;
}
?>
