てみ
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"> </script>
<script>
$(document).ready(function(){
$('#myForm').on('submit', function (e) {
e.preventDefault();
var title = $("#content h1").html();
var subtitle = $("#content h2").html();
var quiz = $("#content h3").html();
console.log(title);
$.ajax({
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){
console.log(data);
}).fail(function (data) {
console.log('failed');
});
});
});
</script>
HTML:
<div id="content">
<h1>title here</h1>
<h2>subtitle</h2>
<h3>quiz</h3>
<form id="myForm" method="POST">
<input type="submit" name="insert" value="Submit">
</form>
</div>
insert_value_mysqli.php
コード怒鳴る:
<?php
$title = $_POST['title'];
$subtitle = $_POST['subtitle'];
$quiz = $_POST['quiz'];
//now you can use insert query
?>
スタートHTMLを作成する方法を求めてから、形。 –
[PHPを使用してHTMLフォームからSQLデータベースにデータを追加する]の可能な複製(http://stackoverflow.com/questions/21683959/add-data-from-html-form-to-a-sql-database-using- php) – ster