我想檢查表單的輸入是否爲空,然後我想使用php代碼進行用戶註冊。如何在javascript中調用php代碼
<script>
$('#submitbutton').click(function(){
if($('#usernameinput').val() == ''){
alert('Input is blank');
}
else {
//here i want to use php codes for example;
$bgl = new mysqli("localhost", "root", "", "users");
if ($bgl->connect_errno) {
echo "Failed to connect to MySQL: (" . $bgl->connect_errno . ") " . $bgl->connect_error;
}
$username = mysql_real_escape_string($_POST['username']);
.....
.....
..... /and so on..
}
});
</script>
當您輸入問題的標題時,會顯示一個列表。點擊這些項目 – PeeHaa
搜索POST方法 –