-1
Gentlemen, I have a problem sending data to the database, because it is learning and testing (first time I connect to the database and send data) I will leave, servername,database,username,.
in the briefcase Uvidoria, I took a form in which I saw in that post in Stackoverflow I created the same database as his because it is the same thing I want to do (I want to get comments and complaints about the site) so I left the same as his changing only the last line (testimony, for comment)
ultima imagem do post é o erro que aprensenta depois de clique em enviar
The files are all in the same folder (in the /public_html) as shown in the image below follows the page Ouvidoria.html where is the client’s fill
<!DOCTYPE HTML>
<html>
<head>
<title>Titulo</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="apple-touch-icon" sizes="180x180" href="img/icone/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="img/icone/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="194x194" href="img/icone/favicon-194x194.png">
<link rel="icon" type="image/png" sizes="192x192" href="img/icone/android-chrome-192x192.png">
<link rel="icon" type="image/png" sizes="16x16" href="img/icone/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
<style>
body {
font: 400 15px Lato, sans-serif;
line-height: 1.8;
color:darkturquoise;
}
h2 {
font-size: 24px;
text-transform: uppercase;
color: #303030;
font-weight: 600;
margin-bottom: 30px;
}
h4 {
font-size: 19px;
line-height: 1.375em;
color: #303030;
font-weight: 400;
margin-bottom: 30px;
}
.jumbotron {
background-color: #33ccff;
color: #fff;
padding: 1px px;
font-family: Montserrat, sans-serif;
margin-top: 2cm;
}
.container-fluid {
padding: 6px 50px;
color: black;
}
.bg-grey {
background-color: #f6f6f6;
}
.logo-small {
color: RED;
font-size: 50px;
}
.logo {
color: #f4511e;
font-size: 200px;
}
.thumbnail {
padding: 0 0 15px 0;
border: none;
border-radius: 0;
}
.thumbnail img {
width: 100%;
height: 100%;
margin-bottom: 10px;
}
.carousel-control.right, .carousel-control.left {
background-image: none;
color: #1176BC;
}
.carousel-indicators li {
border-color: #1176BC;
}
.carousel-indicators li.active {
background-color: blue;
}
.item h4 {
font-size: 19px;
line-height: 1.375em;
font-weight: 400;
font-style: italic;
margin: 70px 0;
}
.item span {
font-style: normal;
}
.panel {
border: 1px solid #33ccff;
border-radius:0 !important;
transition: box-shadow 0.5s;
}
.panel:hover {
box-shadow: 5px 0px 40px rgba(0,0,0, .2);
}
.panel-footer .btn:hover {
border: 1px solid #1176BC;
background-color: #fff !important;
color: #1176BC;
}
.panel-heading {
color: #fff !important;
background-color: #33ccff !important;
padding: 25px;
border-bottom: 1px solid transparent;
border-top-left-radius: 0px;
border-top-right-radius: 0px;
border-bottom-left-radius: 0px;
border-bottom-right-radius: 0px;
}
.panel-footer {
background-color:important;
}
.panel-footer h3 {
font-size: 32px;
}
.panel-footer h4 {
color: #aaa;
font-size: 14px;
}
.panel-footer .btn {
margin: 15px 0;
background-color: green;
color: #fff;
}
.navbar {
margin-bottom: 0;
background-color: #009BCE;
z-index: 9999;
border: 0;
font-size: 12px !important;
line-height: 1.42857143 !important;
letter-spacing: 4px;
border-radius: 0;
font-family: Montserrat, sans-serif;
}
.navbar li a, .navbar .navbar-brand {
color: #fff !important;
}
.navbar-nav li a:hover, .navbar-nav li.active a {
color: black !important;
background-color: #fff !important;
}
.navbar-default .navbar-toggle {
border-color: transparent;
color: #fff !important;
}
footer .glyphicon {
font-size: 10px;
margin-bottom: 10px;
color: #f4511e;
}
.slideanim {visibility:hidden;}
.slide {
animation-name: slide;
-webkit-animation-name: slide;
animation-duration: 1s;
-webkit-animation-duration: 1s;
visibility: visible;
}
@keyframes slide {
0% {
opacity: 0;
transform: translateY(70%);
}
100% {
opacity: 1;
transform: translateY(0%);
}
}
@-webkit-keyframes slide {
0% {
opacity: 0;
-webkit-transform: translateY(70%);
}
100% {
opacity: 1;
-webkit-transform: translateY(0%);
}
}
@media screen and (max-width: 768px) {
.col-sm-4 {
text-align: center;
margin: 25px 0;
}
.btn-lg {
width: 100%;
margin-bottom: 35px;
}
}
@media screen and (max-width: 480px) {
.logo {
font-size: 150px;
}
}
img{
width: 100%;
align-items: center;
}
</style>
</head>
<body id="myPage" data-spy="scroll" data-target=".navbar" data-offset="60">
<nav class="navbar navbar-default navbar-fixed-top ">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#myPage">Inicio</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li><a href="index.html#sobre">Sobre</a></li>
<li><a href="index.html#especialidades">Especialidades</a></li>
<li><a href="index.html#covienios">Convênios</a></li>
<li><a href="index.html#pricing">Partiular</a></li>
<li><a href="index.html#contact">Contato</a></li>
<li><a href="index.html#map">Localização</a></li>
<li><a href="ouvidoria.html">Ouvidoria</a></li>
</ul>
</div>
</div>
</nav>
<div class="row fluid">
<div class="jumbotron text-center">
<h1>Empresa</h1>
<p>Ha mais de 60 anos no ramo !</p>
</div>
</div>
<form action="connection2.php" method="post">
Nome: <input type="text" name="nome"/>
<br>
Email: <input type="text" name="email"/>
<br>
reclamação: <textarea name="comentario" rows="10" cols="80"></textarea> <br/><br/>
<input type="submit" value="Enviar"/>
</form>
</body>
</html>
Follow what you have in the connection2.php file (where you have password and user and location)
<?php
//verifica se existe conexão com bd; caso não tenta, cria uma nova
if ((isset($_POST['email'])) && (!empty($_POST['email']))) {
//porta, usuário, senha, nome data base
//caso não consiga conectar mostra a mensagem de erro mostrada na conexão
$conexao = mysqli_connect("localhost", "id3774441_test123", "teste", "id3774441_test") or die("Erro na conexão com banco de dados " . mysqli_error($conexao));
//Abaixo atribuímos os valores provenientes do formulário pelo método POST
$nome = $_POST['nome'];
$email = $_POST['email'];
$comentario = $_POST['comentraio'];
$string_sql = "INSERT INTO teste (id,nome,email,comentario) VALUES (null,'$nome','$email','$comentario')";
$insert_member_res = mysqli_query($conexao, $string_sql);
if (mysqli_affected_rows($conexao) > 0) { //verifica se foi afetada alguma linha, nesse caso inserida alguma linha
echo "<p>reclamacao Registrado</p>";
echo '<a href="index.html#sobre">Voltar para formulário de cadastro</a>'; //Apenas um link para retornar para o formulário de cadastro
} else {
echo "Erro, não foi possível inserir no banco de dados";
}
mysqli_close($conexao); //fecha conexão com banco de dados
} else {
echo "Por favor, preencha os dados";
}
?>
is yes :/ @Oliveira
– caiquesey
Check that the connection parameters are, https://www.php.net/manual/en/mysqli.construct.php . In order, host, username, passwd, db_name.
– MagicHat
is in order :/
– caiquesey