On a one-page site (site for sales), when trying to click the “Checkout” button, an error pops up Parse error: syntax error, unexpected end of file in … / send.php on line 84
The send.php code itself:
<?php
$phone = $_POST['phone'];
if(empty($phone)) {
?>
<html>
<head><meta http-equiv="content-type"
content="text/html;charset=UTF-8" />
<title>thanks!</title>
</head>
<body style="color: rgb(0, 0, 0); max-width:
980px; min-width: 300px; width: auto;
margin: 0px auto; background-color: rgb(255,
255, 255); font-family: pt sans,arial;">
<br><br>
<center style="padding: 15px 30px; border:
3px solid rgb(63, 63, 63); background-color:
rgb(255, 161, 161);">
<h1 style="font-size: 1.4rem;">You have not entered
required data!<br>
Return to the site and fill out the contact
shape.<br>
</h1></center><br><br>
<a style="display: inline-block;height:
53px;height: 5.3rem;margin: 0px 0
0px;padding: 0 24px; font-size: 1.8rem;
letter-
spacing: 0.02em; line-height: 53px; line-
height: 5.3rem; text-align: center; text-
decoration: none; color: black; transition:
background-color 0.2s ease-out 0s; border-
radius: 7px; text-shadow: 1px 1px 0px
rgba(255, 255, 255, 0.5); -webkit-box-
shadow: inset 0px -3px 0px 0px rgba(50, 50,
50, 0.2); -moz-box-shadow: inset 0px -3px
0px 0px rgba(50, 50, 50, 0.2); box-shadow:
inset 0px -3px 0px 0px rgba(50, 50, 50,
0.2); background: rgb(196, 255, 161);
width:500px;margin:0 auto;display:block;
border: 1px solid #ccc;" href="./"
class='hover'>
Back to site</a>
</body>
</html>
<?
}else {
$email2="[email protected]"; // ------------
----------------------------- mail where
sending a letter
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html;
charset=UTF-8' . "\r\n";
$headers .= 'To: <'.$email2.'>, '."\r\n";
$headers .= 'From: <site.ru>' . "\r\n"; //
---------------------- sender's address,
this is the title of the letter, it is not necessary to change
$subject2 = "Product Name"; // -------
---------------------------------- heading
$message2 = "
<br>Name: ".$_POST['name']."
<br>Telephone: ".$_POST['phone']."
<br>IP-visitor address:
".@$_SERVER['REMOTE_ADDR']."
<br>Order time: ".date('Y-m-d H:i:s').";
";
$mail=mail($email2, $subject2, $message2,
$headers);
if($mail==true){
?>
<html>
<head><meta http-equiv="content-type"
content="text/html;charset=UTF-8" />
<title>thanks!</title></head>
<body style="color: rgb(0, 0, 0); max-width:
980px; min-width: 300px; width: auto;
margin: 0px auto; background-color: rgb(255,
255, 255); font-family: pt sans,arial;">
<br><br>
<center style="padding: 15px 30px; border:
3px solid rgb(63, 63, 63); background-color:
rgb(196, 255, 161);">
<h1 style="font-size: 1.4rem;">Thanks for
Application!<br>
Your application has been accepted and delivered to
processing.<br>
You have provided the following data for feedback:<br><hr>
Name:
<?php
echo $_POST['name'];
?><br>
Telephone:
<?php
echo $_POST['phone'];
?>
</h1></center><br><br>
<a style="display: inline-block;height: 53px;height: 5.3rem;margin: 0px 0 0px;padding: 0 24px; font-size: 1.8rem; letter-spacing: 0.02em; line-height: 53px; line-height: 5.3rem; text-align: center; text-decoration: none; color: black; transition: background-color 0.2s ease-out 0s; border- radius: 7px; text-shadow: 1px 1px 0px rgba(255, 255, 255, 0.5); -webkit-box-shadow: inset 0px -3px 0px 0px rgba(50, 50, 50, 0.2); -moz-box-shadow: inset 0px -3px 0px 0px rgba(50, 50, 50, 0.2); box-shadow: inset 0px -3px 0px 0px rgba(50, 50, 50, 0.2); background: rgb(196, 255, 161); width:500px;margin:0 auto;display:block; border: 1px solid #ccc;" href="./" class='hover'>
Back to site</a>
<!-- below is the metric code(for conversion tracking) -->
<!-- above metric code-->
<style>
.hover:hover {
background:#9FD083 !important;
transition:all .3s ease-in-out;
}
</style>
</body>
</html>
<?
}else{
echo "no";
}
}
?>
Thank you
Answer 1
Pay attention to your comments, for example:
$email2="[email protected]"; // ------------
----------------------------- mail where
sending a letter
here you can see that you only commented out // ------------
this, the bottom lines were left without comment, which is why there is an error. Go through the code and comment out whatever is required
Answer 2
I had the same problem in a similar file, the script worked successfully in PHP 5, and when switching to PHP 7, this error began to appear.
I had suspicions about the following pieces of code:
? & gt; HTML code & lt;? Php
.
Yes, and when I replaced them with
echo ‘HTML code’;
the error is gone.