"".join(["string1", "string2", "string3"]) // "string1string2string"
" ".join(["hello", "world"]) // "hello world"
当我将数据从我的应用程序发送到数据库时,它第一次保存在数据库中并成功返回注册,但是当我再次使用相同的数据时,我的主键是移动号码,当我再次向数据库发送数据时说我注册成功,但实际上这次没有保存数据。我想退回注册失败,那么该怎么办?
这是我的代码:
require "findDoctorConnect.php";
$type = $_POST["type"];
$yourName = $_POST["YourName"];
$RegNum = $_POST["regNum"];
$FatherName = $_POST["fatherName"];
$Gender = $_POST["gender"];
$MobileNumber = $_POST["mobileNumber"];
$Password = $_POST["password"];
$sql_query = "select * from doctorregistration where MobileNumber='$MobileNumber';";
$result = mysqli_query($con, $sql_query);
if (mysqli_num_rows($result) > 0) {
$row = mysqli_fetch_assoc($result);
$temp = $row["MobileNumber"];
if ($temp == $MobileNumber) {
$row = mysqli_fetch_assoc($result);
echo "already found";
}
} else if (mysqli_query($con, $sql_query)) {
$sql_query = "insert into doctorregistration values('$type','$yourName','$RegNum','$FatherName','$Gender','$MobileNumber','$Password');";
$result = mysqli_query($con, $sql_query);
echo "successfull";
}
答案 0 :(得分:0)
在服务器端http://10.0.2.2/findDoctor/register.php
管理此条件并将一些数据返回到Android代码。
在android中使用InputStream
从服务器读取数据,然后检查注册成功与否。
编辑:添加这些行,它将显示正确的输出
InputStream IS=connection.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(IS));
String line;
StringBuilder builder = new StringBuilder();
while((line=reader.readLine()) != null)
builder.append(line);
IS.close();
return builder.toString();
这些行说明,您不关心服务器响应。