This is the registration code of the comment:
<?php
include 'admin/conexao/conecta.php';
if(isset($_POST['comentar'])){
$comentario = trim(strip_tags($_POST['comentario']));
$insert = "INSERT into comentarios (comentario) VALUES (:comentario)";
try{
$result = $conexao->prepare($insert);
$result->bindParam(':comentario', $comentario, PDO::PARAM_STR);
$result->execute();
$contar = $result->rowCount();
if($contar>0){
echo '';
}else{
echo '<script> alert("Erro ao comentar.") </script>';
}
}catch(PDOException $e){
echo $e;
}
?>
<br>
<form method="post" action="#">
<table>
<tr>
<td>
<b>Nome:</b> <br><input style="width: 200px;height: 40px;" type="text" id="autor_coment" name="autor_coment" placeholder="Digite seu nome">
</td>
</tr>
<tr>
<td style="padding-top: 10px;">
<b>Comentário</b> <br>
<textarea style="width: 500px; height: 150px;" type="text" id="comentario" name="comentario" required></textarea>
</td>
</tr>
<tr>
<td style="padding-left: 295px;">
<input class="w3-button w3-black w3-section" style="width:100px; height:40px; background:#333; color:white; border:none;" type="reset" name="cancelar" value="Cancelar"/>
<input class="w3-button w3-black w3-section" style="width:100px; height:40px; background:#333; color:white; border:none;" type="submit" name="comentar" value="Comentar"/>
</td>
</tr>
</table>
</form>
<br>
The problem is that I have no idea how to work with FK
autor_coment
in the register.
What exactly are you having trouble with? Put the code of what you have done so far.
– Diego Vieira
Sql Server or Mysql? Show an error? post the Insert command you are doing
– aa_sp