У меня есть html-форма, которая находится на contact.php, это код
<?php
header('Content-Type: text/html; Charset=utf-8');
mb_internal_encoding('UTF-8');
date_default_timezone_set('Europe/Warsaw');
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Prove</title>
</head>
<body>
<form action="test.php" method="post" name="post">
<label for="email">E-Mail</label>
<input type="email" id="email" name="email" />
<label for="name">Name</label>
<input id="name" name="name" />
<br>
<label> Message: <br><textarea cols="45" rows="6" name="message"></textarea><br></label>
<p>
<button type="submit" name="post" value="POST COMMENT">POST COMMENT</button>
</p>
<br>
</form>
<h2>Comments:</h2>
</body>
</html>
Форма обрабатывается из test.php
<?php
date_default_timezone_set('Europe/Warsaw');
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<?php
include "contact.php";
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['message'])) {
echo "<br><b><h3>*** Please enter all required fields ***</h3></b>";
}
else
{
$name = filter_input( INPUT_POST, 'name', FILTER_SANITIZE_STRING);
$email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_STRING);
$message = filter_input(INPUT_POST, 'message', FILTER_SANITIZE_STRING);
$datetime = date('m/d/Y h:i:s a', time());
echo "<br>"
. "<b>From: </b>" . htmlspecialchars( $name )
. "<b> at: </b>" . htmlspecialchars( $datetime)
. "<br><br>" . htmlspecialchars( $message )
. "<br><hr>";
}
?>
</body>
</html>
Когда пользователь заполняетИз формы и отправить ее, она отображается на test.php вместо contact.php ...
Почему для обеспечения безопасности вместо двух кодов все в одном ...
Мой вопросКак я могу сохранить данные в contact.php?