Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!--PHP variable for active nav link-->
- <?php $pageName = "Home"; ?>
- <!--PHP include statement for header-->
- <?php
- include 'includes/header.php';
- ?>
- <div class="container">
- <div class="page-header">
- <h1>Home</h1>
- </div>
- </div>
- <div class="container">
- <div class="row">
- <!--Posts-->
- <div class="col-md-8">
- <!--Title-->
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "bangalore";
- $dbname = "cms";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT * FROM posts WHERE post_status=\"Published\"";
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- $showPostID = $row['post_id'];
- echo "<a href=\"posts.php?showPostID=" . $row['post_id'] . "\"><h3 class=\"cover-heading\">Post Title: " . $row['post_title'] . "</h3></a>";
- echo "<a href=\"#\"><p>Author: " . $row['post_author'] . "</p></a>";
- echo "<p>Date: " . $row['post_date'] . "</p>";
- echo "<p>" . $row['post_content'] . "</p>";
- echo "<br><br><hr>";
- }
- } else {
- echo "0 results";
- }
- $conn->close();
- ?>
- </div>
- <!--Login and report issue functionalities-->
- <div class="col-md-4">
- <div class="jumbotron">
- <div class="header">
- <h3>Login</h3>
- </div>
- <?php
- echo "<form method=\"post\" action=\"" . basename($_SERVER['PHP_SELF']) . "\">"
- ?>
- <div class="form-group">
- <label>Username</label>
- <input type="text" name="username" class="form-control" placeholder="Username" required>
- </div>
- <div class="form-group">
- <label for="exampleInputPassword1">Password</label>
- <input type="password" name="password" class="form-control" placeholder="Password" required>
- </div>
- <button type="submit" name="Login" class="btn btn-primary center-block" >Login</button><br>
- <a href="#"><p class="text-center">forget password</p></a>
- </form>
- </div>
- <!--Error report panel-->
- <div class="jumbotron">
- <div class="header">
- <h3>Report Issue</h3>
- </div>
- <?php
- echo "<form method=\"post\" action=\"" . basename($_SERVER['PHP_SELF']) . "\">"
- ?>
- <div class="form-group">
- <label>Name</label>
- <input type="text" name="name" class="form-control" placeholder="Preferred Name" required>
- </div>
- <div class="form-group">
- <label>Email address</label>
- <input type="email" name="email" class="form-control" id="exampleInputEmail1" placeholder="E-mail" required>
- </div>
- <div class="form-group">
- <label for="sel1">Select Issue Type</label>
- <select name="sel1" class="form-control" id="sel1">
- <option value="Link not working">Link not working</option>
- <option value="Page not Found">Page not Found</option>
- <option value="Incorrect script">Incorrect script</option>
- </select>
- </div>
- <div class="form-group">
- <label for="message">Message:</label>
- <textarea class="form-control" name="message" rows="5" id="message" required></textarea>
- </div>
- <button type="submit" name="Submit" class="btn btn-success" value="Submit">Submit</button>
- <button type="reset" class="btn btn-info" value="Reset">Reset</button>
- </form>
- <?php
- date_default_timezone_set("America/Halifax");
- $datestuff = date("h.i.s") . "-" . date("Y.m.d");
- $name = "";
- $email = "";
- $message = "";
- $errorType = "";
- if(isset($_POST['Submit'])) {
- $report = fopen("misc/message_" . $datestuff . ".txt", "w") or die("Unable to open file!");
- $name = validate_form_data($_POST['name']);
- $email = validate_form_data($_POST['email']);
- $message = validate_form_data($_POST['message']);
- $alertType = validate_form_data($_POST['sel1']);
- fwrite($report, "Issue Alert!\r\n");
- fwrite($report, "Type of issue: " . $alertType . "\r\n\r\n");
- fwrite($report, "Submitted by: " . $name . "\r\n");
- fwrite($report, "Email ID: " . $email . "\r\n");
- fwrite($report, "Submitted at: " . date("h:i:sa") . " on " . date("Y-M-d") . "\r\n\r\n");
- fwrite($report, "Details: " . $message);
- fclose($report);
- }
- function validate_form_data($formdata){
- $formdata = trim($formdata);
- $formdata = stripslashes($formdata);
- $formdata = htmlspecialchars($formdata);
- return $formdata;
- }
- ?>
- </div>
- </div>
- </div>
- </div><!-- /.container -->
- <?php
- include 'includes/footer.php';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement