я сделал так карочь
<?php
$mysqli = new mysqli('localhost', 'cource', 'cource', 'cource');
$mysqli->set_charset('utf8');
if (mysqli_connect_errno()) {
printf("Соединение не установленно", mysqli_connect_error());
exit();
}
$name = $_POST['name'];
$author = $_POST['author'];
$submit = $_POST['submit'];
if (isset($_POST["submit"])) {
if (isset($_POST["name"], $_POST["author"])) {
$addSound = "INSERT INTO sound VALUES (null, '$name', '$author')";
$mysqli->query($addSound);
echo "+";
} else {
echo "-";
}
}
//session_start();
//$title = "Главная";
include_once "parts/header.php";
?>
<div class="container">
<h1>Sound table</h1>
<br>
<?php
$sounds = $mysqli->query('SELECT * FROM sound');
while ($res = mysqli_fetch_assoc($sounds)) {
echo $res['name']." - ".$res['author']."<br>";
}
$mysqli->close();
?>
<form action="" method="post">
<input type="text" name="name" placeholder="Name" class="form-control"><br>
<input type="text" name="author" placeholder="Author" class="form-control"><br>
<button type="submit" name="submit" class="btn btn-success">Отправить</button>
</form>
</div>
<?php
echo "<br>";
include_once "parts/footer.php"
?>
Сергей Жиглинский
3 years ago