I have some PHP files with session_start() function and some settings to cookie parameters. They are pure PHP pages and there is no HTML at all. Now I want to add some background color and some forms and tables in those PHP pages. When I add any bit of HTML it gives me that error of "headers already passed"!
I want to know the correct way of embedding PHP and HTML! please let me know.
Here is the code:
<?php
include 'functions.php';
secure_session_start();
define("HOST", "localhost"); // The host you want to connect to.
define("USER", "admin"); // The database username.
define("PASSWORD", "password"); // The database password.
define("DATABASE", "test"); // The database name.
$mysqli = new mysqli(HOST, USER, PASSWORD, DATABASE);
if(isset($_POST['name'], $_POST['password'])) {
$name = $_POST['name'];
$password = $_POST['password']; // The hashed password.
if(login($name, $password, $mysqli) == true) {
// Login success
echo 'Success: You have been logged in!';
} else {
// Login failed
echo 'Wrong ID/password!';
}
} else {
// The correct POST variables were not sent to this page.
echo 'Invalid Request';
}
?>