diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..4f60c5a --- /dev/null +++ b/.htaccess @@ -0,0 +1 @@ +SetEnv PORT 8888 diff --git a/includes/config.php b/includes/config.php index 1a041f0..67c6d98 100755 --- a/includes/config.php +++ b/includes/config.php @@ -1,4 +1,5 @@ <?php + $port = getenv("PORT"); $connString = "mysql:host=localhost:8889; dbname=blogdb"; $user="root"; $pass="root"; diff --git a/init.sql b/init.sql index 606b9ce..752d28b 100644 --- a/init.sql +++ b/init.sql @@ -81,6 +81,24 @@ CREATE TABLE IF NOT EXISTS `blogdb`.`comments` ( ENGINE = InnoDB DEFAULT CHARACTER SET = utf8mb4; + +-- ----------------------------------------------------- +-- Table `blogdb`.`contact_form` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `blogdb`.`contact_form` ( + `id_submission` INT NOT NULL AUTO_INCREMENT, + `userid` INT NOT NULL, + `context` TEXT NOT NULL, + PRIMARY KEY (`id_submission`), + UNIQUE INDEX id_submission_UNIQUE (`id_submission` ASC), + CONSTRAINT `userid_FOREIGN_KEY_contact_form` + FOREIGN KEY (`userid`) + REFERENCES `blogdb`.`users` (`idusers`) + ON DELETE CASCADE) +ENGINE = InnoDB +DEFAULT CHARACTER SET = utf8mb4; + + INSERT INTO users (`username`, `email`, `password`) VALUES("Peggy", "foo1@csusm.edu", "12345"); INSERT INTO users (`username`, `email`, `password`) VALUES("Rag", "foo2@csusm.edu", "23456"); INSERT INTO users (`username`, `email`, `password`) VALUES("Brian", "foo3@csusm.edu", "34567"); @@ -104,4 +122,5 @@ INSERT INTO comments (`content`, `userid`, `postid`) VALUES ("Agreed", "4", "3") INSERT INTO comments (`content`, `userid`, `postid`) VALUES ("Agreed", "1", "4"); INSERT INTO comments (`content`, `userid`, `postid`) VALUES ("Agreed", "2", "4"); INSERT INTO comments (`content`, `userid`, `postid`) VALUES ("Agreed", "3", "4"); -INSERT INTO comments (`content`, `userid`, `postid`) VALUES ("Agreed", "4", "4"); \ No newline at end of file +INSERT INTO comments (`content`, `userid`, `postid`) VALUES ("Agreed", "4", "4"); +INSERT INTO contact_form (`userid`, `context`) VALUES ("1", "TEST RUN"); \ No newline at end of file diff --git a/js/login.js b/js/login.js index 7548a1e..54514c0 100644 --- a/js/login.js +++ b/js/login.js @@ -18,7 +18,7 @@ window.addEventListener("load", () => { }) //Checking if user exists with same email - const response = await fetch("http://localhost:8888/php/checkdb.php", { method: "POST", body }); + const response = await fetch("http://localhost:" + port + "/blog/php/checkdb.php", { method: "POST", body }); const data = await response.json() //If user exists does not exist show hint and return early. diff --git a/js/signup.js b/js/signup.js index b979e9d..e406e36 100644 --- a/js/signup.js +++ b/js/signup.js @@ -16,7 +16,7 @@ window.addEventListener("load", () => { }) //Checking if user exists with same email - const response = await fetch("http://localhost:8888/php/checkdb.php", { method: "POST", body }); + const response = await fetch("http://localhost:" + port + "/blog/php/checkdb.php", { method: "POST", body }); const data = await response.json() //If user exists with email show hint and return diff --git a/php/login.php b/php/login.php index 956ccdb..897cbde 100644 --- a/php/login.php +++ b/php/login.php @@ -8,6 +8,10 @@ <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Login</title> + <?php include('../includes/config.php'); ?> + <script> + var port = <?php echo json_encode($port); ?>; + </script> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous"> <link href="../css/login.css" rel="stylesheet" type="text/css" > <link href="../css/top-nav.css" rel="stylesheet" type="text/css"> @@ -40,19 +44,12 @@ </div> </div> <div class="col-8 col-md-6 d-flex justify-content-center"> - <input type="submit" class="login col-8 col-md-6 btn btn-primary mb-3" onclick="home.php"> + <input type="submit" class="login col-8 col-md-6 btn btn-primary mb-3"> </div> </div> </form> <div class="error col-8 col-md-6 d-flex justify-content-center" style="color: red;"></div> </div> - <!-- Footer --> - <!-- <script> - document.querySelector(".login").addEventListener("click", (e) => { - e.preventDefault(); - window.location.href = "home.php"; - }) - </script> --> - <script src="../js/login.js"></script> + <script src="../js/login.js" defer></script> </body> </html> \ No newline at end of file diff --git a/php/signup.php b/php/signup.php index 11fb8bf..30e17e5 100644 --- a/php/signup.php +++ b/php/signup.php @@ -3,7 +3,11 @@ <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <title>Document</title> + <title>Signup</title> + <?php include('../includes/config.php'); ?> + <script> + var port = <?php echo json_encode($port); ?>; + </script> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous"> <link href="../css/signup.css" rel="stylesheet" type="text/css" > <link href="../css/top-nav.css" rel="stylesheet" type="text/css"> @@ -42,7 +46,7 @@ <div class="error col-8 col-md-6 d-flex justify-content-center" style="color: red;"></div> </div> <!-- Footer --> - <script src="../js/signup.js"></script> + <script src="../js/signup.js" defer></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script> </body> </html> \ No newline at end of file