foreach ($n as $values) {
if ($values["PROPERTY_DAYTIME_VALUE"] == 1366 && $values["PROPERTY_TYPE_VALUE"] == 1375) {
$arItem[0]["SUBCATEGORY"][0]["PRODUCTS"][] = $values;
}
}
$sql = 'SELECT * FROM users WHERE login=?';
$query = $pdo->prepare($sql);
$query->execute([$login]);
$user= $query->fetch();
if ($user) {
// вывести ошибку "такой пользователь уже зарегистрирован".
} else {
// твой код на вставку
}
class FileSchemaStorage
{
private $schema;
public function __construct($path,$schemaName)
{
$json = file_get_contents($path . '/' . $schemaName);
if ($schema == false) {
throw new \Exception('Data not found');
}
$this->schema = json_decode($json);
}
public function getAll()
{
return $schema;
}
public function getByName($name){
return $this->schema[$name];
}
}
if ($_POST) {
if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) && $_POST['author'] && $_POST['message']) {
$author = str_replace("\r\n", "", $_POST['author']);
$email = str_replace("\r\n", "", $_POST['email']);
$msg = $_POST['message'];
$time = (int)(microtime(true) * 1000000);
file_put_contents("messages/$time.txt", "$author\n$email\n$msg");
header("Location:".$_SERVER['REQUEST_URI']);
} else {
echo 'Error while adding your message.';
}
}
postMessages();
?>
<form action="index.php" method="post">
<p><input type="text" name="author" required /></p>
<p><input type="text" name="email" required /></p>
<p><textarea name="message" required></textarea></p>
<p><input type="submit" /></p>
</form>