Пример #1
0
<?php

/**
 * Created by PhpStorm.
 * User: wq
 * Date: 12/6/15
 * Time: 1:46 AM
 */
require_once '../database.php';
$email = $_POST['user_email'];
$username = $_POST['user_name'];
$tel = $_POST['user_tel'];
$card = $_POST['user_card'];
$password = $_POST['user_password'];
$succeed = true;
if ($succeed) {
    $db = new database();
    $db->connect_to_db();
    //insert
    $user_re = $db->get_field_from_table('users', 'id', 'id_card', $card);
    if (count($user_re) == 0) {
        $values = array('email' => $email, 'name' => $username, 'tel' => $tel, 'id_card' => $card, 'password' => $password);
        $db->insert_data_into_table('users', $values);
        echo "你的用户";
        echo $username;
        echo "已成功注册!";
    } else {
        echo "注册失败!";
    }
}
Пример #2
0
<?php

/**
 * Created by PhpStorm.
 * User: whx
 * Date: 2015/12/9
 * Time: 20:25
 */
require_once "../database.php";
$conn = new database();
$username = $_SESSION['username'];
$array = array("name" => $username);
$result = $conn->get_field_from_table("users", "id", $array);
echo $result[0]['id'];
Пример #3
0
/**
 * Created by PhpStorm.
 * User: whx
 * Date: 2015/12/5
 * Time: 10:40
 */
require_once "../database.php";
$province = $_GET['province'];
$city = $_GET['city'];
$hospital = $_GET['hospital'];
//$keshi = $_GET['keshi'];
$conn = new database();
if ($province != null && strcmp($province, "") != 0) {
    $keys = array("province" => $province);
    $result = $conn->get_field_from_table("city", "name", $keys);
    echo json_encode($result);
}
if ($city != null && strcmp($city, "") != 0) {
    $keys = array('name' => $city);
    $city_id = $conn->get_field_from_table("city", "id", $keys);
    $city_id_s = $city_id[0]['id'];
    $keys1 = array('city' => $city_id_s);
    $result = $conn->get_field_from_table("hospital", "name", $keys1);
    echo json_encode($result);
}
if ($hospital != null && strcmp($hospital, "") != 0) {
    $keys = array('name' => $hospital);
    $hospital_id = $conn->get_field_from_table("hospital", "id", $keys);
    $hospital_id_s = $hospital_id[0]['id'];
    $keys1 = array('hospital_id' => $hospital_id_s);
Пример #4
0
    echo $html_error_a . "医院详细地址" . $html_error_b;
    $succeed = false;
}
if (strlen($htel) < 1) {
    echo $html_error_a . "医院联系方式" . $html_error_b;
    $succeed = false;
}
if (strlen($hintr) < 1) {
    echo $html_error_a . "医院介绍" . $html_error_b;
    $succeed = false;
}
if ($succeed) {
    $db = new database();
    //search city
    $city_id = 0;
    $city_re = $db->get_field_from_table('city', 'id', 'name', $hcity);
    if (count($city_re) == 0) {
        $valuesci = array('name' => $hcity);
        $db->insert_data_into_table('city', $valuesci);
        $city_re = $db->get_field_from_table('city', 'id', 'name', $hcity);
    }
    $city_id = $city_re[0]['id'];
    //search grade
    $grade_id = 0;
    $grade_re = $db->get_field_from_table('grade', 'id', 'detail', $hgrade);
    if (count($grade_re) == 0) {
        $valuesci = array('detail' => $hgrade);
        $db->insert_data_into_table('grade', $valuesci);
        $grade_re = $db->get_field_from_table('grade', 'id', 'detail', $hgrade);
    }
    $grade_id = $grade_re[0]['id'];
Пример #5
0
<?php 
//登录
require_once '../database.php';
$username = $_POST['username'];
$password = $_POST['password'];
$errmsg = '';
if (!empty($errmsg)) {
    if (empty($username)) {
        $errmsg = "数据输入不完整";
    }
}
if (empty($errmsg)) {
    $db = new database();
    $db->connect_to_db();
    if (mysqli_connect_errno()) {
        $errmsg = "shu ju ku lian jie shi bai!<br>\n";
    } else {
        $realusername = $db->get_field_from_table('users', 'name', 'id_card');
        $realpassword = $db->get_field_from_table('users', 'password', 'id_card');
        if ($username == $realusername && $password == $realpassword) {
            $errmsg = "deng lu cheng gong";
            session_start();
            $_SESSION['uid'] = $username;
            if (empty($_SESSION['uid'])) {
                echo "你还没有登录";
            }
        } else {
            $errmsg = "deng lu shi bai!";
        }
    }
}
Пример #6
0
    echo $html_error_a . "缺少科室名称" . $html_error_b;
    $succeed = false;
}
if (strlen($hbelong) < 1) {
    echo $html_error_a . "缺少科室所属医院" . $html_error_b;
    $succeed = false;
}
if (strlen($hintr) < 1) {
    echo $html_error_a . "缺少科室介绍" . $html_error_b;
    $succeed = false;
}
if ($succeed) {
    $db = new database();
    //search hospital
    $hospital_id = 0;
    $hos_re = $db->get_field_from_table('hospital', 'id', 'name', $hbelong);
    if (count($hos_re) == 0) {
        echo $html_error_a . "未在数据库中发现所属医院信息(请确认信息正确或先添加所属医院信息)" . $html_error_b;
        echo $html_error_return;
    } else {
        $hospital_id = $hos_re[0]['id'];
        $values = array('name' => $hname, 'hospital_id' => $hospital_id, 'intro' => $hintr);
        $db->insert_data_into_table('department', $values);
        echo $html_successa . $hname . "添加成功!" . $html_successb;
    }
} else {
    echo $html_error_return;
}
?>
 
		</body>
Пример #7
0
    echo $html_error_a . "缺少所属医院" . $html_error_b;
    $succeed = false;
}
if (strlen($office) < 1) {
    echo $html_error_a . "缺少所属科室" . $html_error_b;
    $succeed = false;
}
if (strlen($hintr) < 1) {
    echo $html_error_a . "缺少医生介绍" . $html_error_b;
    $succeed = false;
}
if ($succeed) {
    $db = new database();
    //search grade
    $grade_id = 0;
    $grade_re = $db->get_field_from_table('grade', 'id', 'detail', $hlevel);
    if (count($grade_re) == 0) {
        $valuesci = array('detail' => $hlevel);
        $db->insert_data_into_table('grade', $valuesci);
        $grade_re = $db->get_field_from_table('grade', 'id', 'detail', $hlevel);
    }
    $grade_id = $grade_re[0]['id'];
    //search major
    $major_id = 0;
    $major_re = $db->get_field_from_table('major', 'id', 'name', $hmajor);
    if (count($major_re) == 0) {
        $valuesci = array('name' => $hmajor);
        $db->insert_data_into_table('major', $valuesci);
        $major_re = $db->get_field_from_table('major', 'id', 'name', $hmajor);
    }
    $major_id = $major_re[0]['id'];
Пример #8
0
<?php

/**
 * Created by PhpStorm.
 * User: whx
 * Date: 2015/12/8
 * Time: 23:36
 */
require_once "../database.php";
$conn = new database();
$hospital = $_GET['hospital'];
//"北京大学第三医院";
$department = $_GET['department'];
//"骨科";
$keys = array('name' => $hospital);
$hospital_id = $conn->get_field_from_table("hospital", "id", $keys);
$hospital_id_s = $hospital_id[0]['id'];
$keys1 = array('name' => $department);
$department_id = $conn->get_field_from_table("department", "id", $keys1);
$department_id_s = $department_id[0]['id'];
$keys2 = array('hospital_id' => $hospital_id_s, 'department_id' => $department_id_s);
$doctor = $conn->get_field_from_table("doctor", "*", $keys2);
echo json_encode($doctor);
//echo $doctor[0]['name'];
Пример #9
0
<?php

header("Content-type: text/html; charset=utf-8");
require_once 'database.php';
$db = new database();
$values = array('name' => "GuanFuHe", 'password' => "123456");
$db->insert_data_into_table('users', $values);
$key_values = array('province' => '北京市');
print_r($key_values);
$results = $db->get_field_from_table('city', '*', $key_values);
print_r($results);