Пример #1
0
    return $str;
}
if (isset($_POST['action']) && $_POST['action'] == 'save') {
    $conn = new mysqli($mysqlServer, $mysqlUser, $mysqlPass, $mysqlDbName);
    if ($conn->connect_error) {
        die('数据库连接错误:' . $conn->connect_error);
    }
    $username = $_SESSION['username'];
    $name = inputProcess($_POST['name']);
    $sex = inputProcess($_POST['sex']);
    $phone = inputProcess($_POST['phone']);
    $college = inputProcess($_POST['college']);
    $major = inputProcess($_POST['major']);
    $home = inputProcess($_POST['home']);
    if ($_POST['password'] != '') {
        $password = inputProcess($_POST['password']);
        $sql = "UPDATE user SET name='{$name}',sex='{$sex}',phone='{$phone}',college='{$college}',major='{$major}',home='{$home}',password='******' WHERE username='******'";
    } else {
        $sql = "UPDATE user SET name='{$name}',sex='{$sex}',phone='{$phone}',college='{$college}',major='{$major}',home='{$home}' WHERE username='******'";
    }
    $result = $conn->query($sql);
    header('Location: user.php');
    exit;
} else {
    $conn = new mysqli($mysqlServer, $mysqlUser, $mysqlPass, $mysqlDbName);
    if ($conn->connect_error) {
        die('数据库连接错误:' . $conn->connect_error);
    }
    $sql = 'SELECT * FROM user WHERE username="******"';
    $result = $conn->query($sql);
    if ($result->num_rows == 1) {
Пример #2
0
        die('数据库连接错误:' . $conn->connect_error);
    }
    //清空表
    $sql = "TRUNCATE TABLE smsreply";
    $conn->query($sql);
    //查询回复短信并保存
    $sql = "SELECT * FROM user";
    $result = $conn->query($sql);
    if ($result->num_rows > 0) {
        while ($row = $result->fetch_assoc()) {
            $phone = $row['phone'];
            $name = $row['name'];
            $replyResultJson = get_reply($apiKey, $replyUrl, $startTime, $endTime, $phone);
            $replyResult = json_decode($replyResultJson, 'ture');
            $replyText = $replyResult['sms_reply']['0']['text'];
            $replyText = inputProcess($replyText);
            $replyTime = $replyResult['sms_reply']['0']['reply_time'];
            $sql = "INSERT INTO smsreply (phone,name,text,time) VALUES ('{$phone}','{$name}','{$replyText}','{$replyTime}')";
            $conn->query($sql);
        }
    }
    $conn->close();
    header('Location: smsReply.php');
}
?>

<!DOCTYPE html>
<html lang="zh-cn">
<head>
	<meta charset="utf-8">
	<title><?php