diff --git a/comment.php b/comment.php new file mode 100644 index 0000000..eae93d0 --- /dev/null +++ b/comment.php @@ -0,0 +1,121 @@ + 2500) + { + $valid = false; + $commentError = 'Your comment is too long, please shorten it and resubmit'; + } + } + else + { + $valid = false; + $commentError = 'Your comment was empty, please try again.'; + } + } + else + { + header("Location: index.php"); + } + } + else + { + $valid = false; + $commentError = 'Please log in to comment.'; + } + + //Writes to DB only if valid + if($valid == true) + { + //setting non-user input vars + $userId = $_SESSION['user']; + $userId = filter_var($userId, FILTER_SANITIZE_INT); + + $articleId = $_GET['article']; + $articleId = filter_var($articleId, FILTER_SANITIZE_INT); + + $dateCreated = date("Y/m/d"); + + + $pdo = Database::connect(); + $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + //Write to database table comment + $sql = "INSERT INTO comment (user_id,article_id,date_created,comment) values(?, ?, ?, ?)"; + $q = $pdo->prepare($sql); + $q->execute(array($userId,$articleId,$dateCreated,$comment)); + + Database::disconnect(); + + header("Location: " . $prevPage); + } + } + + # Read comments # + else + { + if(isset($_GET['article'])) + { + //Retrieving and sanitizing article id from url + $article = $_GET['article']; + $article = filter_var($article, FILTER_SANITIZE_INT); + + + //needs to join to user table, need to figure that one out + $pdo = Database::connect(); + $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $sql = "SELECT comment.comment, comment.date_created, user.first_name, user.last_name + FROM comment, user + WHERE comment.user_id=user.id + AND comment.article_id=$article + ORDER BY comment.date_created DESC"; + echo($sql); + } + else + { + header: ("index.php"); + } + } + //Open DB + //run article id into comment table order by date_written DESC?? + //write to an array for looping into HTML + +?> \ No newline at end of file diff --git a/create.php b/create.php index a7b7df5..53dc517 100644 --- a/create.php +++ b/create.php @@ -1,153 +1,365 @@ setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $sql = "INSERT INTO customers (name,email,mobile) values(?, ?, ?)"; - $q = $pdo->prepare($sql); - $q->execute(array($name,$email,$mobile)); - Database::disconnect(); - header("Location: index.php"); - } - } - - $type = (isset($_GET['type']) ? $_GET['type'] : null); -?> - - - - - - - + //getting page "type" from url to distinguish between archive, article and user + $type = (isset($_GET['type']) ? $_GET['type'] : null); + + $errors = array(); + + # Another crud if it's creating a user # + if($type == 'user') + { + if(isset($_SESSION['user'])) + { + $userId = $_SESSION['user']; + $userId = filter_var($userId, FILTER_SANITIZE_NUMBER_INT); + + $pdo = Database::connect(); + $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $sql = "SELECT permissions FROM user WHERE id = ?"; + $q = $pdo->prepare($sql); + $q->execute(array($userId)); + $f = $q->fetch(PDO::FETCH_ASSOC); + $permissions = $f['permissions']; + Database::disconnect(); + + if($permissions != 3) + { + header("Location: index.php"); + } + } + else + { + header("Location: index.php"); + } + + + $email = null; + $password = null; + $firstName = null; + $lastName = null; + $dateJoined = null; + $permissions = null; + $avatar = null; + $bio = null; + + + + if (!empty($_POST)) { + // keep track validation errors + $emailError = null; + $passwordError = null; + $firstNameError = null; + $lastNameError = null; + $permissionsError = null; + $avatarError = null; + $bioError = null; + + // keep track post values + $email = $_POST['email']; + $password = $_POST['password']; + $firstName = $_POST['firstName']; + $lastName = $_POST['lastName']; + $permissions = $_POST['permissions']; + $avatar = $_POST['avatar']; + $bio = $_POST['bio']; + + + // validate input + $valid = true; + + # Validate and Sanitize all user input # - -
- setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $sql = "SELECT email FROM user"; + foreach ($pdo->query($sql) as $row) { - ?> - -
-
-

Write an Archive

-
- - + Database::disconnect(); + } + } + else + { + $valid = false; + $emailError = 'Please enter an email address.'; + $errors[] = $emailError; + } -
-
-

Write an Article

-
- - - -
-
- -
- - - - -
-
-
- -
- - - - -
-
-
- -
- - - - -
-
-
- - Back';?> -
-
-
- - 7) + { + $password = password_hash($password, PASSWORD_DEFAULT); + $errors[] = $passwordError; + } + else + { + $valid = false; + $passwordError = 'Password is invalid, please review the guidelines and try again.'; + $errors[] = $passwordError; } + } else { - ?> + $valid = false; + $passwordError = 'Please enter a password.'; + $errors[] = $passwordError; + } -
-

I'm not sure you're meant to be here! PLease return to the homepage here

-
+ if(!empty($firstName)) + { + $firstName = filter_var($firstName, FILTER_SANITIZE_STRING); + if(!preg_match('^[a-zA-Z]{1,25}$', $firstName)) + { + $valid = false; + $firstNameError = 'First name input is invalid, please review the guidelines and try again.'; + $errors[] = $firstNameError; + } + } + else + { + $valid = false; + $firstNameError = 'Please enter your first name.'; + $errors[] = $firstNameError; + } - - -
- - \ No newline at end of file + else + { + $valid = false; + $lastNameError = 'Please enter your last name.'; + $errors[] = $lastNameError; + } + + //Sets avatar image and string + if(!empty($avatar)) + { + require 'imageupload.php'; + if($uploadOk != 1) + { + $valid = false; + $errors[] = $imageError; + } + } + else + { + $image = 'default.jpg'; + } + + if(!empty($bio)) + { + $bio = filter_var($bio, FILTER_SANITIZE_STRING); + if(strlen($password) > 512) + { + $valid = false; + $bioError = 'Your bio is too long, please reduce to 512 characters and resubmit.'; + $errors[] = $bioError; + } + } + else + { + $valid = false; + $bioError = 'Please enter a short personal bio.'; + $errors[] = $bioError; + } + + if(!empty($permissions)) + { + $permissions = filter_var($permissions, FILTER_SANITIZE_NUMBER_INT); + if($permissions < 1 && $permissions > 3) + { + $permissionsError = 'Set permissions are invalid, please revise.'; + $valid = false; + $errors[] = $permissonsError; + } + } + else + { + $permissionsError = 'User permissions need to be set, please try again.'; + $valid = false; + $errors[] = $permissonsError; + } + + # Functions to be run if all input is valid # + if ($valid == true) + { + //Set non-user input variables + $dateJoined = date("Y/m/d"); + + $pdo = Database::connect(); + $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + //Write to database table user + $sql = "INSERT INTO user (email,password,first_name,last_name,date_joined,permissions,avatar,bio) values(?, ?, ?, ?, ?, ?, ?, ?)"; + $q = $pdo->prepare($sql); + $q->execute(array($email,$password,$firstName,$lastName,$dateJoined,$permissions,$avatar,$bio)); + + Database::disconnect(); + } + } + } + + # If changing article or archive # + else + { + if(isset($_SESSION['user'])) + { + $userId = $_SESSION['user']; + $userId = filter_var($userId, FILTER_SANITIZE_NUMBER_INT); + + $pdo = Database::connect(); + $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $sql = "SELECT permissions FROM user WHERE id = ?"; + $q = $pdo->prepare($sql); + $q->execute(array($userId)); + $f = $q->fetch(PDO::FETCH_ASSOC); + $permissions = $f['permissions']; + Database::disconnect(); + + if($permissions < 2 || $permissions > 3) + { + header("Location: index.php"); + } + } + else + { + header("Location: index.php"); + } + + $valid = true; + + $name = null; + $image = null; + $content = null; + $date = null; + $author = null; + $category = null; + + if (!empty($_POST)) { + // keep track validation errors + $nameError = null; + $imageError = null; + $contentError = null; + $categoryError = null; + + + //including image upload scripts + require 'imageupload.php'; + + echo($valid); + + + //adding in quickfacts vars in case of archive + if ($type == 'archive') + { + $quickFactsError = null; + $quickFacts = $_POST['quickFacts']; + } + + // keep track post values + $name = $_POST['name']; + $content = $_POST['content']; + $category = $_POST['category']; + + // validate input + $valid = true; + if (empty($name)) { + $nameError = 'Please enter the '.$type.'\'s name'; + $valid = false; + $errors[] = $nameError; + } + + if (empty($image)) { + //$imageError = 'Please upload a feature image'; + $valid = false; + $errors[] = $imageError; + } + + + //need to set up image errors + + if (empty($content)) { + $contentError = 'Please enter some content'; + $valid = false; + $errors[] = $contentError; + } + + if (empty($category)) { + $categoryError = 'Please choose a category'; + $valid = false; + $errors[] = $categoryError; + } + + if ($type == 'archive') + { + if (empty($quickFacts)) { + $quickFactsError = 'Please enter the archive\'s quick facts'; + $valid = false; + $errors[] = $quickFactsError; + } + } + + // insert data + if ($valid == true) { + //setting non-user input vars + $date = date("Y/m/d"); + $author = $userId; + echo ($date); + echo($author); + if ($type == 'archive') + { + $pdo = Database::connect(); + $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $sql = "INSERT INTO archive (archive_name,image,content,date_created,author_id,category,quick_facts) values(?, ?, ?, ?, ?, ?, ?)"; + $q = $pdo->prepare($sql); + $q->execute(array($name,$image,$content,$date,$author,$category,$quickFacts)); + Database::disconnect(); + header("Location: index.php?page=crud&type=article"); + } + elseif ($type == 'article') + { + $pdo = Database::connect(); + $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $sql = "INSERT INTO article (article_name,image,content,date_created,author_id,category) values(?, ?, ?, ?, ?, ?)"; + $q = $pdo->prepare($sql); + $q->execute(array($name,$image,$content,$date,$author,$category)); + Database::disconnect(); + header("Location: index.php?page=crud&type=article"); + } + else + { + header("Location: index.php"); + } + } + } + } +?> \ No newline at end of file diff --git a/createform.php b/createform.php new file mode 100644 index 0000000..8913196 --- /dev/null +++ b/createform.php @@ -0,0 +1,217 @@ +
+ +
+ $error

"); + } + echo("
"); + } + ?> +
+

Create a User

+
+ '; + ?> +
+ +
+ + + + +
+
+ +
+ +
+ + + + +
+
+ +
+ +
+ + + + +
+
+ +
+ +
+ + + + +
+
+ +
+ +
+ + + + +
+
+ +
+ +
+ + + + +
+
+ +
+ +
+ + + + +
+
+ +
+ + Back';?> +
+ +
+ +
+ +
+ $error

"); + } + ?> +
+ +
+ Write an Archive'); + } + else + { + echo('

Write an Article

'); + } + + ?> +
+ '; + ?> +
+ +
+ + + + +
+
+ +
+ +
+ + + + +
+
+ +
+ +
+ + + + +
+
+ +
+ +
+ + + + +
+
+ +
+ +
+ + + + +
+
+ +
+ + Back';?> +
+ +
+ + + +
+

I'm not sure you're meant to be here! Please return to the homepage here

+
+ + \ No newline at end of file diff --git a/crud.php b/crud.php index abb7fa0..dd787e8 100644 --- a/crud.php +++ b/crud.php @@ -8,11 +8,11 @@ } elseif ($type == "archive") { - $sql = 'SELECT * FROM article WHERE is_archive=1 ORDER BY id DESC'; + $sql = 'SELECT * FROM archive ORDER BY id DESC'; } elseif ($type == "article") { - $sql = 'SELECT * FROM article WHERE is_archive=0 ORDER BY id DESC'; + $sql = 'SELECT * FROM article ORDER BY id DESC'; } ?> @@ -39,7 +39,7 @@

query($sql))) { ?> diff --git a/dbBackup/conspirator.sql b/dbBackup/conspirator.sql index f70a02b..a3dc50d 100644 --- a/dbBackup/conspirator.sql +++ b/dbBackup/conspirator.sql @@ -3,7 +3,7 @@ -- http://www.phpmyadmin.net -- -- Host: 127.0.0.1 --- Generation Time: Nov 19, 2014 at 09:17 AM +-- Generation Time: Nov 29, 2014 at 09:23 AM -- Server version: 5.6.16 -- PHP Version: 5.5.11 @@ -23,15 +23,20 @@ SET time_zone = "+00:00"; -- -------------------------------------------------------- -- --- Table structure for table `archive_facts` +-- Table structure for table `archive` -- -CREATE TABLE IF NOT EXISTS `archive_facts` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `archive_id` int(11) NOT NULL, - `content` text NOT NULL, +CREATE TABLE IF NOT EXISTS `archive` ( + `id` int(11) NOT NULL DEFAULT '0', + `archive_name` varchar(30) NOT NULL, + `image` varchar(50) NOT NULL, + `content` mediumtext NOT NULL, + `date_created` date NOT NULL, + `author_id` int(11) NOT NULL, + `category` varchar(35) NOT NULL, + `quick_facts` text NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- @@ -46,38 +51,12 @@ CREATE TABLE IF NOT EXISTS `article` ( `content` mediumtext NOT NULL, `date_created` date NOT NULL, `author_id` int(11) NOT NULL, - `category_id` int(11) NOT NULL, - `is_archive` tinyint(1) NOT NULL, + `category` varchar(35) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- --- --- Table structure for table `category` --- - -CREATE TABLE IF NOT EXISTS `category` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `cat_name` varchar(25) NOT NULL, - `css_link` varchar(50) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ; - --- --- Dumping data for table `category` --- - -INSERT INTO `category` (`id`, `cat_name`, `css_link`) VALUES -(1, 'history', 'styles/history.css'), -(2, 'evilCorps', 'styles/evilcorps.css'), -(3, 'aliens', 'styles/aliens.css'), -(4, 'exoticCreatures', 'styles/exotic.css'), -(5, 'urbanLegends', 'styles/urbanleg.css'), -(6, 'endOfDays', 'styles/endofdays.css'); - --- -------------------------------------------------------- - -- -- Table structure for table `comment` -- diff --git a/dbBackup/createbackup.php b/dbBackup/createbackup.php new file mode 100644 index 0000000..d2892ba --- /dev/null +++ b/dbBackup/createbackup.php @@ -0,0 +1,636 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $sql = "SELECT permissions FROM user WHERE id = ?"; + $q = $pdo->prepare($sql); + $q->execute(array($userId)); + $f = $q->fetch(PDO::FETCH_ASSOC); + $permissions = $f['permissions']; + Database::disconnect(); + + if($permissions != 3) + { + header("Location: index.php"); + } + } + else + { + header("Location: index.php"); + } + + + $email = null; + $password = null; + $firstName = null; + $lastName = null; + $dateJoined = null; + $permissions = null; + $avatar = null; + $bio = null; + + + + if (!empty($_POST)) { + // keep track validation errors + $emailError = null; + $passwordError = null; + $firstNameError = null; + $lastNameError = null; + $permissionsError = null; + $avatarError = null; + $bioError = null; + + // keep track post values + $email = $_POST['email']; + $password = $_POST['password']; + $firstName = $_POST['firstName']; + $lastName = $_POST['lastName']; + $permissions = $_POST['permissions']; + $avatar = $_POST['avatar']; + $bio = $_POST['bio']; + + + // validate input + $valid = true; + + # Validate and Sanitize all user input # + + + if (!empty($email)) + { + $email = filter_var($email, FILTER_SANITIZE_EMAIL); + $email = filter_var($email, FILTER_VALIDATE_EMAIL); + if(empty($email)) + { + $valid = false; + $emailError = 'Email invalid, please try again.'; + $errors[] = $emailError; + } + else + { + $pdo = Database::connect(); + $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $sql = "SELECT email FROM user"; + foreach ($pdo->query($sql) as $row) + { + if($row['email'] == $email) + { + $valid = false; + $emailError = 'Email address is already in use, please try a different one.'; + $errors[] = $emailError; + } + } + Database::disconnect(); + } + } + else + { + $valid = false; + $emailError = 'Please enter an email address.'; + $errors[] = $emailError; + } + + if (!empty($password)) + { + $password = filter_var($password, FILTER_SANITIZE_STRING); + if (ctype_alnum($password) && strlen($password) > 7) + { + $password = password_hash($password, PASSWORD_DEFAULT); + $errors[] = $passwordError; + } + else + { + $valid = false; + $passwordError = 'Password is invalid, please review the guidelines and try again.'; + $errors[] = $passwordError; + } + } + else + { + $valid = false; + $passwordError = 'Please enter a password.'; + $errors[] = $passwordError; + } + + if(!empty($firstName)) + { + $firstName = filter_var($firstName, FILTER_SANITIZE_STRING); + if(!preg_match('^[a-zA-Z]{1,25}$', $firstName)) + { + $valid = false; + $firstNameError = 'First name input is invalid, please review the guidelines and try again.'; + $errors[] = $firstNameError; + } + } + else + { + $valid = false; + $firstNameError = 'Please enter your first name.'; + $errors[] = $firstNameError; + } + + if(!empty($lastName)) + { + $lastName = filter_var($lastName, FILTER_SANITIZE_STRING); + if(!preg_match('^[a-zA-Z]{1,25}$', $lastName)) + { + $valid = false; + $lastNameError = 'Last name input is invalid, please review the guidelines and try again.'; + $errors[] = $lastNameError; + } + } + else + { + $valid = false; + $lastNameError = 'Please enter your last name.'; + $errors[] = $lastNameError; + } + + //Sets avatar image and string + if(!empty($avatar)) + { + require 'imageupload.php'; + if($uploadOk != 1) + { + $valid = false; + $errors[] = $imageError; + } + } + else + { + $image = 'default.jpg'; + } + + if(!empty($bio)) + { + $bio = filter_var($bio, FILTER_SANITIZE_STRING); + if(strlen($password) > 512) + { + $valid = false; + $bioError = 'Your bio is too long, please reduce to 512 characters and resubmit.'; + $errors[] = $bioError; + } + } + else + { + $valid = false; + $bioError = 'Please enter a short personal bio.'; + $errors[] = $bioError; + } + + if(!empty($permissions)) + { + $permissions = filter_var($permissions, FILTER_SANITIZE_NUMBER_INT); + if($permissions < 1 && $permissions > 3) + { + $permissionsError = 'Set permissions are invalid, please revise.'; + $valid = false; + $errors[] = $permissonsError; + } + } + else + { + $permissionsError = 'User permissions need to be set, please try again.'; + $valid = false; + $errors[] = $permissonsError; + } + + # Functions to be run if all input is valid # + if ($valid == true) + { + //Set non-user input variables + $dateJoined = date("Y/m/d"); + + $pdo = Database::connect(); + $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + //Write to database table user + $sql = "INSERT INTO user (email,password,first_name,last_name,date_joined,permissions,avatar,bio) values(?, ?, ?, ?, ?, ?, ?, ?)"; + $q = $pdo->prepare($sql); + $q->execute(array($email,$password,$firstName,$lastName,$dateJoined,$permissions,$avatar,$bio)); + + Database::disconnect(); + } + } + ?> + + + + + + + + + + + + +
+
+ + +
+ + $error

"); + } + ?> + +
+ + +
+

Create a User

+
+ '; + ?> +
+ +
+ + + + +
+
+ +
+ +
+ + + + +
+
+ +
+ +
+ + + + +
+
+ +
+ +
+ + + + +
+
+ +
+ +
+ + + + +
+
+ +
+ +
+ + + + +
+
+ +
+ +
+ + + + +
+
+ +
+ + Back';?> +
+ +
+
+ + +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $sql = "SELECT permissions FROM user WHERE id = ?"; + $q = $pdo->prepare($sql); + $q->execute(array($userId)); + $f = $q->fetch(PDO::FETCH_ASSOC); + $permissions = $f['permissions']; + Database::disconnect(); + + if($permissions < 2 || $permissions > 3) + { + header("Location: index.php"); + } + } + else + { + header("Location: index.php"); + } + + $valid = true; + + $name = null; + $image = null; + $content = null; + $date = null; + $author = null; + $category = null; + + if (!empty($_POST)) { + // keep track validation errors + $nameError = null; + $imageError = null; + $contentError = null; + $categoryError = null; + + + //including image upload scripts + require 'imageupload.php'; + + echo($valid); + + + //adding in quickfacts vars in case of archive + if ($type == 'archive') + { + $quickFactsError = null; + $quickFacts = $_POST['quickFacts']; + } + + // keep track post values + $name = $_POST['name']; + $content = $_POST['content']; + $category = $_POST['category']; + + // validate input + $valid = true; + if (empty($name)) { + $nameError = 'Please enter the '.$type.'\'s name'; + $valid = false; + $errors[] = $nameError; + } + + if (empty($image)) { + //$imageError = 'Please upload a feature image'; + $valid = false; + $errors[] = $imageError; + } + + + //need to set up image errors + + if (empty($content)) { + $contentError = 'Please enter some content'; + $valid = false; + $errors[] = $contentError; + } + + if (empty($category)) { + $categoryError = 'Please choose a category'; + $valid = false; + $errors[] = $categoryError; + } + + if ($type == 'archive') + { + if (empty($quickFacts)) { + $quickFactsError = 'Please enter the archive\'s quick facts'; + $valid = false; + $errors[] = $quickFactsError; + } + } + + // insert data + if ($valid == true) { + //setting non-user input vars + $date = date("Y/m/d"); + $author = $userId; + echo ($date); + echo($author); + if ($type == 'archive') + { + $pdo = Database::connect(); + $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $sql = "INSERT INTO archive (archive_name,image,content,date_created,author_id,category,quick_facts) values(?, ?, ?, ?, ?, ?, ?)"; + $q = $pdo->prepare($sql); + $q->execute(array($name,$image,$content,$date,$author,$category,$quickFacts)); + Database::disconnect(); + header("Location: index.php?page=crud&type=article"); + } + elseif ($type == 'article') + { + $pdo = Database::connect(); + $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $sql = "INSERT INTO article (article_name,image,content,date_created,author_id,category) values(?, ?, ?, ?, ?, ?)"; + $q = $pdo->prepare($sql); + $q->execute(array($name,$image,$content,$date,$author,$category)); + Database::disconnect(); + header("Location: index.php?page=crud&type=article"); + } + else + { + header("Location: index.php"); + } + } + } + ?> + + + + + + + + + + + + +
+
+ + +
+ + $error

"); + } + ?> + +
+ + +
+ Write an Archive'); + } + else + { + echo('

Write an Article

'); + } + + ?> + +
+
+ + '; + ?> +
+ +
+ + + + +
+
+ +
+ +
+ + + + +
+
+ +
+ +
+ + + + +
+
+ + + +
+ +
+ + + + +
+
+ + + +
+ +
+ + + + +
+
+ +
+ + Back';?> +
+ +
+ + + +
+

I'm not sure you're meant to be here! Please return to the homepage here

+
+ + + +
+ + + \ No newline at end of file diff --git a/delete.php b/delete.php index 7a762b2..7aa5431 100644 --- a/delete.php +++ b/delete.php @@ -1,7 +1,9 @@ setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $sql = "DELETE FROM customers WHERE id = ?"; + $sql = "DELETE FROM article WHERE id = ?"; $q = $pdo->prepare($sql); $q->execute(array($id)); Database::disconnect(); - header("Location: index.php"); - - } + header("Location: index.php?page=crud&type=article"); + } + + elseif($type == 'archive') + { + $pdo = Database::connect(); + $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $sql = "DELETE FROM archive WHERE id = ?"; + $q = $pdo->prepare($sql); + $q->execute(array($id)); + Database::disconnect(); + header("Location: index.php?page=crud&type=archive"); + } + } ?> - - - - - - - -
- -
-
-

Delete a Customer

-
- -
- -

Are you sure to delete ?

-
- - No -
-
-
- -
- + + + + + + + +
+ +
+ + +
+

Delete an Article

+
+ + +
+

Delete an Archive

+
+ + '; + ?> + + +

Are you sure you want to delete ?

+
+ + + No'; + ?> + +
+ +
+ +
+ \ No newline at end of file diff --git a/images/Aliens1.png b/images/Aliens1.png new file mode 100644 index 0000000..427b0cb Binary files /dev/null and b/images/Aliens1.png differ diff --git a/images/Aliens2.png b/images/Aliens2.png new file mode 100644 index 0000000..427b0cb Binary files /dev/null and b/images/Aliens2.png differ diff --git a/images/Bloody_Mary.png b/images/Bloody_Mary.png new file mode 100644 index 0000000..9f0430e Binary files /dev/null and b/images/Bloody_Mary.png differ diff --git a/images/Bloody_Mary1.png b/images/Bloody_Mary1.png new file mode 100644 index 0000000..9f0430e Binary files /dev/null and b/images/Bloody_Mary1.png differ diff --git a/images/article/area51.jpeg b/images/article/area51.jpeg new file mode 100644 index 0000000..2c77e81 Binary files /dev/null and b/images/article/area51.jpeg differ diff --git a/imageupload.php b/imageupload.php new file mode 100644 index 0000000..320bb4e --- /dev/null +++ b/imageupload.php @@ -0,0 +1,86 @@ + 1000000) + { + $imageError = 'Sorry, your file is too large'; + $uploadOk = 0; + } + + // Check file format + + if($imageFileType != "gif" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "jpg") + { + $imageError = 'Sorry, only JPG, JPEG, PNG and GIF files are allowed'; + $uploadOk = 0; + } + + // Check if $uploadOk is true try to upload image and set path as DB value + + if ($uploadOk == 1) + { + if (move_uploaded_file($_FILES["image"]["tmp_name"], $targetFile)) + { + $upload = $targetFile; + } + else + { + $imageError = 'Sorry, there was an error uploading your file'; + } + } + + +?> \ No newline at end of file diff --git a/index.php b/index.php index 57e5212..05054f8 100644 --- a/index.php +++ b/index.php @@ -1,5 +1,17 @@ @@ -14,9 +26,28 @@ + + + + + + + - + -
- -
- +
+ +
+ +
+ - - +
-