I have added a review section to my website. It works perfectly but the w3 validator shows errors about stray tags (Doctype, Html, Head, body...)
The review section generates contents and consists of php, css and js files. I have put all files into the folder "recensioni" and I have included the index.php path inside the body of my homepage. recensioni/index.php includes in turns php files with html tags. These tags become duplicated in the main html and affects its flow: "Error: Stray doctype". ... "Start tag body seen but an element of the same type was already open" "End tag for body seen, but there were unclosed elements"
Homepage index.php:
<!DOCTYPE html>
...
<p id="recensioni" style="height:10px;"></p>
<div class="group-container txt-center" >
<h1 >CHI HA FREQUENTATO DICE</h1>
<div class= "back-corsi">
<?php include_once $_SERVER['DOCUMENT_ROOT']. '/recensioni/index.php';?>
</div>
</div>
...
recensioni/index.php:
...
include 'recensioni.html.php';
try {
$sql='SELECT * FROM corsi';
$result=$pdo->query($sql);
}
catch (Exception $e) {
$error='Errore nel recupero recensioni: ' . $e->getMessage();
header('Location: .?errorDB=218');
exit();
}
foreach ($result as $row) {
$corsi[]=array ('id'=>$row['id'], 'corso'=>$row['nome_corso']);
}
include 'nuova_recensione.html.php';
nuova_recensione.html.php:
<!DOCTYPE html>
...
<body onload="<?php if($location==="inputField"){ ?> location.href='#inputField'; <?php } if (isset($action)){ ?> alert_message() <?php } ?>">
<?php
if (isset($action)){?>
<div id="dialog-message" title="<?php echo htmlout($title);?>">
<p id="message"><?php echo htmlout($message) ?></p>
</div>
<?php } ?>
<div class="row row-one-colunm-padding">
...
How can I solve? What solution should I adopt? Thanks
nuova_recensione.html.phpis a PHP file, so you can omit<!DOCTYPE html>from that file. This will also avoid pulling in two of those tags, and another set of<head>,<body>etc.. Also, there's no need for.html.php, you can simply name it.phpas the extension. The file type is strictly for you to know what it contains by just looking at it. - Brxxn<link>'s and everything else where they are, you can remove<!DOCTYPE html>without issues. - Brxxn