-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2e0fd34
Showing
43 changed files
with
27,302 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
try { | ||
$connect = mysqli_connect("localhost", "root", "", "jwpcp_db"); | ||
if(!$connect){ | ||
throw new Exception('Unable to connect'); | ||
} | ||
} catch (Exception $e) { | ||
echo 'Message: ' .$e->getMessage(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
session_start(); | ||
if(!$_SESSION){ | ||
header('Location:index.php'); | ||
exit(); | ||
} | ||
|
||
include('connection.php'); | ||
|
||
$title = $_POST['title']; | ||
$cover_url = $_POST['cover_url']; | ||
$content = $_POST['content']; | ||
|
||
$insert = mysqli_query($connect,"INSERT INTO posts SET title='$title', cover_url='$cover_url', content='$content'"); | ||
|
||
if($insert) | ||
header('Location:posts.php?msg=true'); | ||
else | ||
header('Location:posts.php?msg=false'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<?php | ||
session_start(); | ||
if(!$_SESSION){ | ||
header('Location:index.php'); | ||
exit(); | ||
} | ||
|
||
?> | ||
<!doctype html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
<title>Simple Blog - Codepolitan</title> | ||
|
||
<!-- Bootstrap CSS --> | ||
<link rel="stylesheet" href="css/bootstrap.min.css"> | ||
|
||
<!-- Dependencies --> | ||
<script src="js/jquery-3.4.1.slim.min.js"></script> | ||
<script src="js/popper.min.js"></script> | ||
<script src="js/sweetalert.min.js"></script> | ||
|
||
<!-- Bootstrap JS --> | ||
<script src="js/bootstrap.bundle.min.js"></script> | ||
|
||
</head> | ||
|
||
<body class="bg-light"> | ||
<header> | ||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark justify-content-between"> | ||
<a class="navbar-brand" href="index.php">Simple Blog</a> | ||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> | ||
<span class="navbar-toggler-icon"></span> | ||
</button> | ||
|
||
<div class="collapse navbar-collapse" id="navbarSupportedContent"> | ||
<ul class="navbar-nav ml-auto"> | ||
<li class="nav-item active"> | ||
<a class="nav-link" href="index.php">Home</a> | ||
</li> | ||
|
||
<?php if(!$_SESSION) : ?> | ||
<li class="nav-item active"> | ||
<a class="nav-link" href="login.php">Login</a> | ||
</li> | ||
<?php endif; ?> | ||
|
||
<?php if($_SESSION) : ?> | ||
<li class="nav-item dropdown"> | ||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | ||
Hi, <?php echo $_SESSION['username'] ?> | ||
</a> | ||
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown"> | ||
<a class="dropdown-item" href="dashboard.php">Dashboard</a> | ||
<a class="dropdown-item" href="logout.php">Log Out</a> | ||
</div> | ||
</li> | ||
<?php endif; ?> | ||
</ul> | ||
</div> | ||
</nav> | ||
</header> | ||
<main role="main"> | ||
<div class="container-fluid"> | ||
<div class="row"> | ||
<div class="col-md-3"> | ||
<div class="list-group mt-4"> | ||
<a href="profile.php" class="list-group-item list-group-item-action">Profile</a> | ||
<a href="posts.php" class="list-group-item list-group-item-action">Posts</a> | ||
</div> | ||
</div> | ||
<div class="col-md-9"> | ||
<div class="card shadow mt-4"> | ||
<div class="card-header"> | ||
<h4>Posts - Create Post</h4> | ||
</div> | ||
<div class="card-body"> | ||
<form action="create-post-action.php" method="POST"> | ||
<div class="form-group"> | ||
<label for="exampleInputTitle">Title</label> | ||
<input type="text" name="title" class="form-control" id="exampleInputTitle"> | ||
</div> | ||
<div class="form-group"> | ||
<label for="exampleInputCoverImage">URL Image</label> | ||
<input type="text" name="cover_url" class="form-control" id="exampleInputCoverImage"> | ||
</div> | ||
<div class="form-group"> | ||
<label for="exampleInputContent">Content</label> | ||
<textarea class="form-control" name="content" id="exampleInputContent"></textarea> | ||
</div> | ||
<button type="submit" class="btn btn-block btn-primary">Publish now!</button> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</main> | ||
</body> | ||
|
||
</html> |
Oops, something went wrong.