-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.php
More file actions
32 lines (31 loc) · 1.19 KB
/
Copy pathdb.php
File metadata and controls
32 lines (31 loc) · 1.19 KB
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
<?php
$host="localhost";
$user="root";
$password="";
$db="Portfolio";
$conn=new mysqli($host,$user,$password);
$conn->query("CREATE DATABASE IF NOT EXISTS $db");
$conn->select_db($db);
$conn->query("CREATE TABLE IF NOT EXISTS contact (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(100) NOT NULL,
message TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)");
$conn->query("CREATE TABLE IF NOT EXISTS projects (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
description TEXT,
link VARCHAR(255),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)");
$checkDummy = $conn->query("SHOW TABLES LIKE 'flag'");
if ($checkDummy->num_rows == 0){
$conn->query("INSERT INTO projects (name, description, link) VALUES
('Portfolio Website', 'Personal portfolio showcasing projects', 'https://github.com/Abir-49/Portfolio.git'),
('Java Algorithms', 'Implementation of different algorithms in Java', 'https://github.com/Abir-49/Java.git'),
('Hello World', 'A simple Java hello world application using Maven', 'https://github.com/Abir-49/helloworld.git')");
$conn->query("CREATE TABLE flag (id INT AUTO_INCREMENT PRIMARY KEY)");
}
?>