$email = $_POST['email']; $phone = $_POST['phone']; $address = $_POST['address']; $error = null; $saved = false; try { $dsn = 'mysql:dbname=bookweb;host=140.127.74.142'; $user = '******'; $password = '******'; $db = new PDO($dsn, $user, $password); $db->exec("set names utf8"); $accountCheck = searchAccount($db, $account); if ($accountCheck) { insertAccount($db, $account, $pwd); $u_id = searchID($db, $account); insertUserInfo($db, $name, $dept, $degree, $email, $phone, $address, $u_id); $saved = true; } else { $error = "account"; $saved = false; } } catch (PDOException $e) { $error = $e; } $result = array("result" => $saved, "responseDetail" => $error); $json_result = json_encode($result); echo $json_result; //----exit---- function searchAccount($db, $account) { $stmt = $db->prepare('SELECT * from `user` WHERE account = :account');
} } else { echo "Wrong User Name"; } } if (isset($_POST["signup"])) { $inputEmail = $_POST["inputEmail"]; $name = $_POST["name"]; $inputPassword = $_POST["inputPassword"]; $retypePassword = $_POST["retypePassword"]; $institutionName = $_POST["institutionName"]; $photo = ""; if (selectUserInfo($inputEmail) != null) { echo "This email already used for another account !"; } else { insertUserInfo($inputEmail, $inputPassword, $name, $institutionName, $photo); $_SESSION["currentUser"] = $_POST["inputEmail"]; echo "successful"; } } if (isset($_POST["saveTheExam"])) { $examName = $_POST["examName"]; $startDateTime = $duration = ""; if (isset($_POST["year"])) { $d = $_POST["year"] . "-" . $_POST["month"] . "-" . $_POST["day"] . " " . $_POST["hour"] . ":" . $_POST["minute"]; $startDateTime = date("Y-m-d H:i:s", strtotime($d)); //echo $startDateTime; } if (isset($_POST["durationHour"])) { $duration = date("H:i:s", strtotime($_POST["durationHour"] . ":" . $_POST["durationMinute"])); }
//'Woshizhu3312'; $db_name = 'db03152'; //'qdm163951542_db'; $conn = new mysqli($db_server, $db_account, $db_password, $db_name, '3306'); if ($conn->connect_error) { die('数据库连接失败!' . $conn->connection_error); return; } //插入信息 $userKey = getKey(); function insertUserInfo($conn, $userKey) { $sql = 'insert into game_redbag_data(ip, start_time, userKey) values("' . getIP() . '","' . date('y-m-d H:i:s') . '", "' . $userKey . '")'; $conn->query($sql); } insertUserInfo($conn, $userKey); //生成随机码 function getKey() { return uniqid('user', true); } //获取ip function getIP() { $ip = '未知ip'; if (!empty($_SERVER['HTTP_CLIENT_IP'])) { return is_ip($_SERVER['HTTP_CLIENT_IP']) ? $_SERVER['HTTP_CLIENT_IP'] : $ip; } else { if (!empty($_SERVER['HTTP_X_FORWARD_FOR'])) { return is_ip($_SERVER['HTTP_X_FORWARD_FOR']) ? $_SERVER['HTTP_X_FORWARD_FOR'] : $ip; } else {