hello guysはajaxを使用してアカウントを作成しようとしています。すべて正常に動作する問題は年齢であり、コンタクト番号は登録時に働いていませんeverydataは年齢と連絡先番号を除いて挿入できますので、問題が発生しました 年齢と連絡先番号はデータベースに挿入できません )register.jsデータを挿入する際にエラーが発生しました
$(document).ready(function(e){
$('#register').click(function(){
var Bdate = document.getElementById('createbday').value;
var Bday = +new Date(Bdate);
Q4A = ~~ ((Date.now() - Bday)/(31557600000));
var theBday = document.getElementById('createage');
theBday.innerHTML = Q4A.val;
var createusername = $('#createusername').val();
var createpassword = $('#createpassword').val();
var creategivenname = $('#creategivenname').val();
var createmiddlename = $('#createmiddlename').val();
var createlastname = $('#createlastname').val();
var createbday = $('#createbday').val();
var age = Q4A;
var creategender = $('#creategender').val();
var contactnumber = $('#createcontactnumber').val();
var createaddress = $('#createaddress').val();
var createcity = $('#createcity').val();
$.ajax({
type : 'POST',
data :{createusername:createusername,
createpassword:createpassword,
creategivenname:creategivenname,
createmiddlename:createmiddlename,
createlastname:createlastname,
createbday:createbday,
age:age,
creategender:creategender,
contactnumber:contactnumber,
createaddress:createaddress,
createcity:createcity},
url :"insert.php",
success : function(result){
if(result)
{
$('#error').html("<span>Success Man</span>");
$('#createusername').val('');
$('#createpassword').val('');
$('#creategivenname').val('');
$('#createmiddlename').val('');
$('#createlastname').val('');
$('#createbday').val('');
$('#createage').val('');
$('#creategender').val('');
$('#createcontactnumber').val('');
$('#createaddress').val('');
$('#createcity').val('');
}
}
})
});
}の のindex.php
<div class="col-md-4">
<label for="createage">Age</label>
<input id="createage" name="createage" class="form-control" type="text" >
</div>
<div class="col-md-6">
<label for="createcontactnumber">Contact Number</label>
<input id="createcontactnumber"
name="createcontactnumber"
class="form-control"
oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
type = "number" maxlength = "11"/>
</div>
オン;
register.php
<?php
$connect = mysqli_connect("localhost", "root", "", "thaidatabase");
$username = $_POST['createusername'];
$password = $_POST['createpassword'];
$givenname = $_POST['creategivenname'];
$middlename = $_POST['createmiddlename'];
$lastname = $_POST['createlastname'];
$bday = $_POST['createbday'];
$age = $_POST['createage'];
$gender = $_POST['creategender'];
$contactnumber = $_POST['createcontactnumber'];
$address = $_POST['createaddress'];
$city = $_POST['createcity'];
mysqli_query($connect,"insert into account (username,password,givenname,middlename,lastname,bday,age,gender,contactnumber,address,city)
values
('$username','$password','$givenname','$middlename','$lastname','$bday','$age','$gender','$contactnumber','$address','$city City')");
mysqli_close($connect);
?>
画像の代わりにここにコードを投稿してください – JYoThI
コードは問題のコードではなく、リンクではありませんし、確かに画像ではありません。 –
申し訳ありませんが、私はすでに投稿を更新します – NeCat