實現的功能就是遠程注冊登錄後,跳轉到首頁,首頁顯示歡迎信息,並把服務器從數據庫取回的數據以json格式返回,並顯示在listview上,登錄用戶的代碼是參考一位壇友的本地注冊登錄的實例。
服務器端:server.php
<?php
include('dbconfig.php');
$address = $_POST['address'];
$longitude = $_POST['longitude'];
$latitude = $_POST['latitude'];
if(empty($address) or empty($longitude) or empty($latitude)){
die("You have to fill all the fields!");
}
$conn = mysql_connect($server,$username,$password);
if(!$conn){
die("connection failed:".mysql_error());
}
mysql_select_db($dbName,$conn);
$query = "insert into ".$tableName." values(NULL,'".$address."',".$longitude.",".$latitude.",'".date('Y-m-d H:i:s',time())."');";
$result = mysql_query($query,$conn);
if(!$result){
die("mysql error:".mysql_error());
}
echo "add information to database sucessfullly!";
?>