Exemple #1
0
<?php

include_once 'php/config.php';
define("PAGENAME", "Create New");
include_once 'include/header.php';
$user = new USER($conn);
if (!$user->loggedin()) {
    $user->redirect('login');
}
$userID = $_SESSION['user_session'];
$stmt = $conn->prepare("SELECT * FROM user WHERE userID=:userID");
$stmt->execute(array(":userID" => $userID));
$userRow = $stmt->fetch(PDO::FETCH_ASSOC);
if (isset($_POST['send_post'])) {
    $title = trim($_POST['title']);
    $subtitle = trim($_POST['subtitle']);
    $preview = trim($_POST['preview']);
    $main_text = trim($_POST['main_text']);
    //improving quality of the code, adding empty method to check for empty variables
    if (empty($title)) {
        $error[] = "Oh no! You need a title for your post!";
    } else {
        if (empty($subtitle)) {
            $error[] = "Oh no! You need a subtitle for your post!";
        } else {
            if (empty($preview)) {
                $error[] = "Oh no! What's your extract?";
            } else {
                if (empty($main_text)) {
                    $error[] = "Oh no! C'mon, you need to write your post! This is a blog, afterall!";
                } else {
Exemple #2
0
?>
 </title>


			<link href="css/import.css" rel="stylesheet" type="text/css">
			<meta name="viewport" content="width=device-width, initial-scale=1">
			<!-- meta tags for SEO-->
			<meta name="description" content="Bloggie, content oriented blogging platform">
			<meta http-equiv="content-type" content="text/html;charset=UTF-8">

		</head>
		<body>
			<!-- Navigation -->

				<?php 
if (!$session->loggedin()) {
    ?>
				<nav>
				<div class="first">
					<a href="index"><img src="img/logo-small.png" alt="logo, or get back to the index page" class="logo" width="100" height="77"></a>
					<!-- only shows up on a mobile device: tablet or a phone -->
					<span class="icon-search responsive hidden"></span>
				</div>

				<div class="middle">
					<a href="all_posts">latest blogs</a>
				</div>
				<div class="middle">
					<a href="login">login</a>
				</div>
				<div class="middle">
Exemple #3
0
<?php

require_once 'php/session.php';
require_once 'php/user.php';
//new user object
$user_logout = new USER($conn);
//if user login has a session redirects to index
if ($user_logout->loggedin() != "") {
    $user_logout->redirect('index');
}
//if the session and url gets logout then logout and redirect
if (isset($_GET['logout']) && $_GET['logout'] == "true") {
    $user_logout->logout();
    $user_logout->redirect('index.php');
}
Exemple #4
0
<?php

include_once 'php/config.php';
define("PAGENAME", "Register");
include_once 'include/header.php';
$user = new USER($conn);
//creating object user
if ($user->loggedin() != "") {
    $user->redirect('dashboard.php');
    //redirect to dashboard
}
//once signup input is clicked ...
if (isset($_POST['signup'])) {
    //getting rid of whitespace around sqlite_unbuffered_query
    $email = trim($_POST['email']);
    $password = trim($_POST['password']);
    $confirmed_password = trim($_POST['confirm_password']);
    //checking whether the form is filled correctly
    if ($email == "") {
        $error[] = "Provide your email!";
    } else {
        if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
            $error[] = 'Please enter a valid email address!';
        } else {
            if ($password == "") {
                $error[] = "Provide a password!";
            } else {
                if (strlen($password) < 6) {
                    $error[] = "Password must be atleast 6 characters";
                } else {
                    if (strlen($confirmed_password) < 6) {
Exemple #5
0
<?php

include_once 'php/config.php';
$login = new USER($conn);
define("PAGENAME", "Login");
include_once 'include/header.php';
//if logged in already rediret
if ($login->loggedin() != "") {
    $login->redirect('dashboard');
}
//if not, then check details through running a method
if (isset($_POST['login_button'])) {
    $email = $_POST['email'];
    $pass = $_POST['password'];
    if ($login->login($email, $pass)) {
        $login->redirect('dashboard');
    } else {
        $error = "Wrong Details!";
    }
}
?>

				<header class="big-header">
						<h1 class="no-margin">Please, log in</h1>
			</header>

			<div class="intro bottom-margin">
				<form method="post" class="inputs feat first">
					<div class="light-green">
						<h2>Just fill in your details</h2>
					</div>