<?php
header("Content-type:text/html;charset=utf-8"); //設定編碼
$servername = "localhost";
$username = "root";
$password = "1234";
$dbname = "login";
// 建立連線
$conn = mysqli_connect($servername, $username, $password, $dbname);
mysqli_set_charset($conn,'utf8'); //設定字元集
# // 偵測連線
if (!$conn) {
die("連線失敗: " . mysqli_connect_error());
#}
/ / 使用sql 建立資料表
$sql = "CREATE TABLE user (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(30) NOT NULL,
password VARCHAR(30) NOT NULL
);";
if (mysqli_query($conn, $sql)) {
echo "資料表user 建立成功";
} else {
echo "建立資料表錯誤: " . mysqli_error($conn);
#}
mysqli_close ($conn);
?>
吖