-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
50 lines (37 loc) · 1.13 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
// MySQL database configuration
$servername = "localhost"; // Replace with your servername
$username = "root"; // Replace with your MySQL username
$password = ""; // Replace with your MySQL password
// Create a connection to MySQL server
$conn = new mysqli($servername, $username, $password);
// Check for connection errors
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Create a new database named "classxii"
$sql = "CREATE DATABASE classxii";
if ($conn->query($sql) === TRUE) {
echo "Database created successfully";
} else {
echo "Error creating database: " . $conn->error;
}
// Select the "classxii" database
$conn->select_db("classxii");
// Create a new table named "users"
$sql = "CREATE TABLE users (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) NOT NULL,
email VARCHAR(50) NOT NULL,
phone bigint(11) NOT NULL,
password VARCHAR(50) NOT NULL
)";
if ($conn->query($sql) === TRUE) {
echo "Table created successfully";
} else {
echo "Error creating table: " . $conn->error;
}
// Close the database connection
$conn->close();
header('Location: login.php');
?>