How do I place the data of a php form in a Heidisql table

Asked

Viewed 111 times

0

I have a contact form at php, when we submit an email with the entered data.

What I wanted was to insert this data into a table in the program Heidisql.

Form code:

     <div class="pagina" id="contactos">
      <head>  
       <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script> 

     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  


    <font align= center face= "Comic Sans MS" size=+1 Color= #003d99>
    <?php echo "<p>Contacte-nos</p>"; ?>

</head>


        <Fieldset>             
        <div align="left">
        <form> 
            <legend align="left"> Submeter Coment&agraverios </legend>
            <br />
            <form id="submit_form">     
                    Nome: <input type="text" name="name" placeholder="Jo&atilde;o Santos"required="" id="name" class="form-control" type="text" size =20 />  
                     <br />  
                    Email: <input type="email" name="email" value="" placeholder="[email protected]" size=20 required id="email" class="form-control" />
                     <br /> 
                     <br />
                    <input TYPE="checkbox" NAME="Remember Me" VALUE="op1" NOT_CHECKED> Remind me    
                    <input Type="Reset" Value="Limpar" />

                </form>  
        </Fieldset>
        <div align="left">
        <br>
        <legend align="left"> Coment&aacuterios  </legend>
        <Textarea id="comentarios" name="comentarios"  value="" cols=35 rows=5 ></Textarea>
        <br>
        <br> 
        <fieldset> 
            <legend align="left"> Bot&otilde;es de comando </legend>            
            <input type="button" name="submit" id="submit" class="btn btn-info" value="Submit" />  
                     <span id="error_message" class="text-danger"></span>  
                     <span id="success_message" class="text-success"></span>

        </fieldset>
        <?php echo htmlentities($user_message)?></textarea>
           </div>  
      </body>  
 </html>        

<script>  
 $(document).ready(function(){  
      $('#submit').click(function(){  
           var name = $('#name').val();  
           var email = $('#email').val();  
           var comentarios = $('#comentarios').val();
           if(name == '' || email == '' || comentarios == '')  
           {  
                $('#error_message').html("Necessita de preencher todos os campos");  
           }  
           else  
           {  

                $.ajax({  
                     url:"Succesmsg.php",  
                     method:"POST",                                         
                     data:{name:name, email:email, comentarios:comentarios},  
                     success:function(data){  
                          $("form").trigger("reset");  
                          $('#success_message').fadeIn().html(data);  
                          setTimeout(function(){  
                               $('#success_message').fadeOut("Slow");  
                          }, 9999);  
                     }  
                });  
           }  
      });  
 });  
 </script>  
</div>
  • It is a normal Mysql database entry, Heidisql is not a database itself, you will not put data in a table of it but in a database and it will just display this table to you in a friendly way. I suggest you study more about database, to record form information in a table you can use this library I made: https://github.com/LeonardoVilarinho/MinPDO

  • To do Insert, Oce edits mipdo.php and puts the credentials of your database (if you have not changed anything in the settings then just leave as this) then you use MinPDO::insert("tabela", array("coluna1", "coluna2"), array("valor1", "valor2");

  • Ivcs can please provide the code for mipdo.php?

  • Just take the github link I mentioned in the first comment. Then click Clone or download and then Download ZIP

  • Yes I realized, what is the difference between the variable $sgbd and $dbname

  • sgbd is the type of database that in your case is "mysql" and "dbname" is the name you gave to your database.

  • It does not work when I run the example and click on 1.(Insert) of this error " Parse error: syntax error, Unexpected '@', expecting ',' or ')' in H: working2014@stages exercicios php minpdo.php on line 15" the code is $Conn = new PDO(self::$mysql.":host=".self::$mail.fusadeen.pt.";dbname=".self::$exercises.";charset=utf8;", self::[email protected], self::$pass);

  • not so, you are with wrong understanding about php, follows the tutorial on github:https://github.com/LeonardoVilarinho/MinPDO/wiki if you don’t understand the tutorial I suggest you study more about php and programming languages themselves

  • I understand yes, but how do I do it? How do I embed this code in mine? I require the minpdo.php file in my index.php?

Show 4 more comments
No answers

Browser other questions tagged

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