<?php
include_once("model/articlesFunctions.php");
$fields = ['titel' => '', 'content' => ''];
$err = '';
if($_SERVER['REQUEST_METHOD'] === 'POST') {
$fields['titel'] = trim($_POST['titel']);
$fields['content'] = trim($_POST['content']);
if($fields['titel'] == '' || $fields['content'] == ''){
$err = 'Заполните все поля!';
}
else{
articlesAdd($fields);
header('Location: index.php');
exit();
}
}
?>
<div class="form">
<form method="post">
Name:<br>
<input type="text" name="titel" value="<?=$fields['titel']?>"><br>
Text:<br>
<textarea name="text"><?=$fields['content']?></textarea><br>
<button>Send</button>
<p><?=$err?></p>
</form>
</div>
function articlesAdd(array $fields) : bool {
$sql = "INSERT INTO articles ('titel', 'content') VALUES (:titel, :content)";
dbQuery($sql, $fields);
return true;
}
<form method="post">
не хватает action
, куда шлются данные function articlesAdd(array $fields) : bool {
$sql = "INSERT INTO articles ('titel', 'content') VALUES (:titel, :content)";
var_dump([$fields,$sql]);exit();
dbQuery($sql, $fields);
return true;
}