-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig.php
60 lines (48 loc) · 1.97 KB
/
config.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
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/*
* Auther : Tauseed Zaman
*/
$host = "localhost";
$username = "root";
$password = "";
$db = "testPHP";
$conn = mysqli_connect($host, $username, $password) or die('connection error');
// create database if not esits
$query = "create database if not exists $db";
mysqli_query($conn,$query) or die("con't create database");
$query = "USE $db";
mysqli_query($conn,$query) or die(" database dones not selected");
$query = "CREATE TABLE IF NOT EXISTS `phonesDirectory` (
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(100) NOT NULL ,
`phone` VARCHAR(25) NOT NULL ,
`user_id` INT UNSIGNED NOT NULL,
`created_at` DATETIME NULL DEFAULT CURRENT_TIMESTAMP ,
`updated_at` DATETIME NULL DEFAULT CURRENT_TIMESTAMP ,
PRIMARY KEY (`id`)
-- FOREIGN KEY (user_id) REFERENCES customers(id)
) ENGINE = InnoDB
";
mysqli_query($conn, $query) or die("con't create phonesDirectory table". mysqli_error($conn));
// $query = "CREATE TABLE `users` (
// `id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
// `user_id` int(10) unsigned NOT NULL ,
// `email` varchar(255) NOT NULL,
// `username` varchar(255) NOT NULL,
// `password` varchar(255) NOT NULL,
// `created_at` timestamp NULL DEFAULT current_timestamp(),
// `updated_at` timestamp NULL DEFAULT current_timestamp(),
// PRIMARY KEY (`id`),
// -- CONSTRAINT `users_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `phonedirectory` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
// ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4";
$query="CREATE TABLE IF NOT EXISTS `users` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`email` VARCHAR(255) NOT NULL ,
`username` VARCHAR(255) NOT NULL ,
`password` VARCHAR(255) NOT NULL ,
`created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ,
`updated_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ,
PRIMARY KEY (`id`)) ENGINE = InnoDB";
mysqli_query($conn, $query) or die("con't create users table". mysqli_error($conn));
header('Location: register.php');
?>