ster ster - 1 year ago 47
HTML Question

insert value in mysqli from h1 html

I have the file index.php:

<div id="content">
<h4> title </h4>
<h3> subtitle </h3>
<h4> quiz </h4>
<form action="insert_value_mysqli.php" method="POST">
<input type="submit" name="insert" value="Submit">

How can i assign attributes or how can i insert in the table below these texts: title, subtitle and quiz? Or what procedures to use to introduce values in the table?

| 1 | title |
| 2 | subtitle |
| 3 | quiz |

Thank you!

Answer Source

Try with jquery and php :

Jquery :

<script src="">   </script>   

    $('#myForm').on('submit', function (e) {
        var title = $("#content h1").html();
        var subtitle = $("#content h2").html();
        var quiz = $("#content h3").html();
            url: "insert_value_mysqli.php", // Url to which the request is send
            type: "POST", // Type of request to be send, called as method
            data: {title:title, subtitle:subtitle, quiz:quiz}, // Data sent to server, a set of key/value pairs representing form fields and values
            dataType: 'json'
        }).done(function (data){
        }).fail(function (data) {


<div id="content">
    <h1>title here</h1>
    <form id="myForm" method="POST">
        <input type="submit" name="insert" value="Submit">

insert_value_mysqli.php code bellow :

  $title = $_POST['title'];
  $subtitle = $_POST['subtitle'];
  $quiz = $_POST['quiz'];
  //now you can use insert query
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download