Because the form only worked once

Asked

Viewed 23 times

0

Hello I made a small form and it only worked once , I didn’t change the code after that and it doesn’t work anymore what it could be ?

<?php
error_reporting(-1);
ini_set('display_errors', 'On');

//Criar a conexao
$link = new mysqli ("localhost", "root", "", "peixaria");
if($link->connect_errno){
     echo"Nossas falhas local experiência ..";
     exit();
}

if($_SERVER['REQUEST_METHOD'] == 'POST') {
    $mesa = $_POST['mesa'];
    $nome = $_POST['nome'];
    $telefone = $_POST['telefone'];
        $sql="INSERT INTO nreserva(mesa,nome,telefone) VALUES('$mesa','$nome','$telefone')";
        $resultado_reserva = mysqli_query($link,$sql);
}
?>
<!DOCTYPE html>
     <html>
      <head>
      <meta charset="UTF-8">
          <meta name="viewport" content="width=device-width, initial-scale=1">
        <body>
        <title>Reserva</title>
    <h1>Peixaria</h1>
    <ul class="menu cf">
      <li><a href="secao.php">Início</a></li>
      <li><a href="pedidos.php">Pedidos</a></li>
      <li><a href="reserva.php">Reserva</a></li>
      <li><a href="relatorio.php">Relatório</a></li>
    </ul>
    <br>
    <main>
      <form method="post" action="reserva.php">
        <header>
          <h2>Reserva</h2>
        </header>
        <fieldset>
          <label>
            <span>Mesa:</span>
            <input type="text" name="mesa"value="">
          </label>
          <label>
            <span>Nome:</span>
            <input type="text" name="nome" value="">
          </label>
          <label>
            <span>Telefone:</span>
            <input type="tel" name="telefone"value="">
          </label>
        </fieldset>
        <br>
<button class="btn" type="submit">Fazer Reserva</button>   
      </form>
    </main>
</body>

1 answer

0


It is possible that you have given error in mysql, because depending on how you created the table, the primary key was repeated. Try looking at the php log to see which error has occurred.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.