I'm trying to insert data via form in PHP. However, I'm having an error, I can not find this error at all.
As I said, I'm wanting to enter data, via SELECT INTO
Please note:
insert.php, it is in this tab that I will enter the data.
<h3>Formulário de Cadastro de Sinaps</h3><br>
<form name="Cadastro" action="insere_dados.php" method="POST">
<label>Nome do programa: </label>
<input type="text" name="programa" size="30"><br>
<label>versa do programa: </label>
<input type="text" name="versaoprograma" size="45"><br>
<label>Data de Publicação: </label>
<input type="text" name="data" size="45"><br>
<br>
<input type="submit" name="enviar" value="Enviar">
</form>
insert_dates.php, this tab will make the insert.php function
<?php
$programa = $_POST['programa'];
$versaoprograma = $_POST['versaoprograma'];
$data = $_POST['data'];
$strcon = mysqli_connect('localhost','root','','atualizacao') or die('Erro ao conectar ao banco de dados');
$sql = "INSERT INTO geral (nomedopograma, versaodoprograma, datadoprograma) VALUES ('$programa', '$versaoprograma', '$data')";
mysqli_query($strcon,$sql) or die("Erro ao tentar cadastrar registro");
mysqli_close($strcon);
echo "Cliente cadastrado com sucesso!";
?>
update.php, this tab will receive data from insert.php
<?php
// Propriedades BD
define("HOST", "localhost");
define("USER", "root");
define("PASS", "");
define("BDNAME", "atualizacao");
@mysql_connect(HOST, USER, PASS) or die("Não foi possivel se conectar ao servidor");
mysql_select_db(BDNAME) or die("Não foi possível se conectar ao banco de dados") ;
?>
<?php
$sql = mysql_query("SELECT * FROM geral");
while($exibe = mysql_fetch_assoc($sql)){
echo "<ul class='col-md-12 item1'>";
echo "<li class='nomedoprograma'>".$exibe["nomedoprograma"]."</li>";
echo "<li class='versao'>".$exibe["versaodoprograma"]."</li>";
echo "<li class='atualizacao'>".$exibe["datadoprograma"]."</li>";
echo "</ul>";
}
?>
When I fill in the data and click send, the only message that appears is Error trying to register record ,
Database
-- phpMyAdmin SQL Dump -- version 4.6.4 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: 24-Abr-2017 às 15:32 -- Versão do servidor: 5.7.14 -- PHP Version: 5.6.25 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Database: 'atualizacao' -- -- -------------------------------------------------------- -- -- Estrutura da tabela 'geral' -- CREATE TABLE 'geral' ( 'nomedoprograma' varchar(50) CHARACTER SET utf8 NOT NULL, 'versaodoprograma' varchar(20) CHARACTER SET utf8 NOT NULL, 'datadoprograma' date NOT NULL, 'comentarios' varchar(1024) CHARACTER SET utf8 NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Extraindo dados da tabela 'geral' -- INSERT INTO 'geral' ('nomedoprograma', 'versaodoprograma', 'datadoprograma', 'comentarios') VALUES ('Sinap280', 'Versao 200', '2017-04-24', ''), ('Sinap280', 'Versao 200', '2017-04-24', ''), ('', 'versao100', '2017-04-24', ''), ('Sinap 8024', '1090', '2017-04-24', ''); /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
This is the database.