Form does not reach the database

0

I created a form in HTML / PHP, it concludes and I decided to connect the form to my database by XAMPP and everything ran without presenting any errors, until then I tried to send a form and saved it in the BD, but in the others attempts did not save any more information and also does not display any error message at all, what can it be?

Follow the codes:

HTML:

<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <title>Fleisch Berg Co.</title>
    <link rel="stylesheet" href="css/trabalho.css">

</head>
<body>
    <header>
        <div id="cabecalho">
            <h1><img src="img/logo.png"></h1>    
        </div>
    </header>

    <nav class="menu">

        <ul>
             <li id="lmenu"><a href="index.html">Home</a></li>
             <li id="lmenu"><a href="fleisch.html">A&nbspFleish&nbspBerg&nbspCo.</a>
             <li id="lmenu"><a href="#">Lançamentos</a>
             <li id="lmenu"><a href="#">História</a>
             <li id="lmenu"><a href="#">Loja&nbspVirtual</a>
             <li id="lmenu"><a href="trabalho.html">Trabalhe&nbspconosco</a>
             <li id="lmenu"><a href="#">Contatos</a></li></li>     
        </ul>

    </nav>

    <div id="noti">
        <h3>Trabalhe conosco:</h3>

        <form method="post" id="jobform" action="jobs.php">
           <fieldset id="job"><legend>Identificação pessoal</legend>

           <p>Nome completo: <input type="text" name="tnome" id="cnome" size="25" maxlength="25" placeholder="Digite seu nome" required></p>
           <p>Data de nascimento: <input type="date" name="tidade" id="cidade" required></p>
           <p>Telefone: <input type="text" name="ttel" id="ctel" size="7" maxlength="7" placeholder="Seu telefone aqui" required></p>
           <fieldset id="gene"><legend>Gênero</legend>
                <input type="radio" name="tsexo" id="cmasc" required value="homem">  
                <label for="cmasc">Masculino</label><br/>
                <input type="radio" name="tsexo" id="cfem" required value="mulher">
                <label for="cfem">Feminino</label>
           </fieldset>
           <p>Endereço: <input type="text" name="tend" id="cend" size="35" maxlength="35" placeholder="Endereço aqui" required></p>
           <p><label for="cesc">Grau de escolaridade:</label></p>
           <textarea name="tesc" id="cesc" cols="40" rows="10" placeholder="Escreva seus cursos aqui" required=""></textarea>
           <p><label for="cexp">Experiência profissional:</label></p>
           <textarea name="texp" id="cexp" cols="45" rows="10" placeholder="Fala aqui as suas experiências profissíonais" required=""></textarea>
           <p><label for="csobre">Fala um pouco sobre você:</label></p>
           <textarea name="tsobre" id="csobre" cols="45" rows="10" placeholder="Fala um pouco sobre você aqui" required=""></textarea>
           <p><label for="cvaga" required>Vaga desejada:</label>
            <select name="tvaga" id="cvagas" required="">
                <option selected>Escolha a vaga</option>
                <option>Diretor</option>
                <option>Encarregado</option>
                <option>Guarda</option>
                <option>Secretária</option>
                <option>Ajudante Geral</option>
                <option>Caminhoneiro (Fixo)</option>
                <option>Caminhoneiro (Temporário)</option>
            </select>
           </fieldset>

            <P>
                <INPUT type="reset"  name="tres" value="Limpar">
                <INPUT type="submit" name="tenv" value="Enviar">
            </P>

        </form>


    </div>

    <footer>
        <div id="rodape">
            <img id="icone" src="img/icone.png">
            <p id="copy">© Copyright 2000-2018 Fleisch Berg Company S.A.</p>
        </div>
    </footer>
</body>
</html>

PHP (Form):

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>Fleisch Berg Co.</title>
  <link rel="stylesheet" href="css/trabalho.css">
</head>

<body>
  <?php


            include_once ('connection/conexao.php');
            $nome = $_POST['tnome'];
            $nasc = $_POST['tidade'];
            $tel = $_POST['ttel'];
            $gen = $_POST['tsexo'];
            $end = $_POST['tend'];
            $esco = $_POST['tesc'];
            $exp = $_POST['texp'];
            $sobre = $_POST['tsobre'];
            $vaga = $_POST['tvaga'];

            $formulariojobs = "INSERT INTO formjobs (nome, nasc, tel, gen, ende, esco, exp, sobre, vaga) VALUES ('$nome', '$nasc', '$tel', '$gen', '$end', '$esco', '$exp', '$sobre', '$vaga', NOW())";
            $resultado_msg_contato = mysqli_query($conn, $formulariojobs);




        ?>
    <a href="trabalho.html">Voltar</a>
</body>

</html>

PHP (CONNECTION):

<?php 
    $servidor = "localhost";
    $usuario = "root";
    $senha = "";
    $dbname = "jobs";

    //criar a conexão

    $conn = mysqli_connect($servidor, $usuario, $senha, $dbname);


?>
    
asked by anonymous 03.07.2018 / 21:52

1 answer

3

You are specifying 9 fields to receive the information, however you send 10 information:

$formulariojobs = "INSERT INTO formjobs (nome, nasc, tel, gen, ende, esco, exp, sobre, vaga) VALUES ('$nome', '$nasc', '$tel', '$gen', '$end', '$esco', '$exp', '$sobre', '$vaga', NOW())";

You are submitting:

  • '$ name'
  • '$ nasc'
  • '$ tel'
  • '$ gen'
  • '$ end'
  • '$ esc'
  • '$ exp'
  • '$' '
  • '$ vacancy'
  • NOW
  • But you assign these values only to:

  • name
  • nasc
  • tel
  • gen
  • ende
  • esco
  • exp
  • about
  • vacancy
  • You must have the same number of assignments and parameters.

    @edit

    To fix your other problem, do the following:

  • Create a new field in your table of type integer. You can name it however you want, but I'll call it'id'
  • Define this new field with "auto increment" and "primary key"
  • Save and try again to insert records in the database.
  • 03.07.2018 / 22:35