Ehsan_collboy Posted April 13, 2022 Share Posted April 13, 2022 <?php require_once("include/db.php"); require_once("include/redirect.php"); require_once("include/session.php"); require_once("datatime.php"); ?> <?php $searchqueryparameters = $_GET["id"]; $currenttime = time(); $datetime = strftime("%B-%d-%Y %H:%M:%S",$currenttime); ?> <?php if(isset($_POST["Submit"])) { $email = $_POST["commenteremail"]; $name = $_POST["commentername"]; $comments = $_POST["comments"]; if(empty($name)) { $_SESSION["ErrorMessage"] = "All fields must bee fills"; redirect("fullpost.php"); } elseif(strlen($name)<3) { $_SESSION["ErrorMessage"] = "Please Enter Valid Lenght of Category"; redirect("fullpost.php"); }elseif(strlen($name)>25) { $_SESSION["ErrorMessage"] = "Name Title less then 25 Chracters"; redirect("fullpost.php"); }elseif (strlen($coments) < 3) { $_SESSION["ErrorMessage"] = "Please Enter Valid Lenght of Category"; redirect("fullpost.php"); }elseif (strlen($coments) > 500) { $_SESSION["ErrorMessage"] = "Your Comments is grater then 500"; redirect("fullpost.php"); } else { $sql = "INSERT INTO comments(name,datetime,email,comments)"; $sql .= "VALUES(:name,:email,:datetime,comments)"; $stmt = $cn->prepare($sql); $stmt->bindValue(":name",$name); $stmt->bindValue(":email",$email); $stmt->bindValue(":comments",$comments); $stmt->bindValue(":datetime",$datetime); $sucess = $stmt->execute(); if($sucess) { $_SESSION["successMessage"] = "Comments Has Been POST waiting for approve "; redirect("index.html"); }else { $_SESSION["ErrorMessage"] = "System Error Try Again..!"; redirect("fullpost.php"); } } } ?> <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="CSS/style.css"> <script src="https://kit.fontawesome.com/46936f93f7.js" crossorigin="anonymous"></script> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css" integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" crossorigin="anonymous"> <title>Live Blog Full Post</title> </head> <body> <!---navbar--> <div style="height: 10px; background: #27aae1;"></div> <nav class="navbar navbar-expand-lg navbar-dark bg-dark"> <div class="container"> <a href="#" class="navbar-brand" >BummerStyle.com</a> <button class="navbar-toggler" data-toggle="collapse" data-target="#navbarcollapseCMS"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarcollapseCMS"> <ul class="navbar-nav mr-auto"> <li class="nav-item"> <a href="blog.php" class="nav-link">Home</a> </li> <li class="nav-item"> <a href="#" class="nav-link">About Us</a> </li> <li class="nav-item"> <a href="#" class="nav-link">Contacts Us</a> </li> <li class="nav-item"> <a href="#" class="nav-link">Feature</a> </li> </ul> <ul class="navbar-nav ml-auto"> <form class="form-inline d-none d-sm-block" action="blog.php"> <div class="form-group"> <input class="form-control mr-2" name="search" type="text" placeholder="Search Here"> <button name="searchbutton" class="btn btn-primary">Go</button> </div> </form> </ul> </div> </div> </nav> <div style="height: 10px; background: #27aae1;"></div> <!---navbar End--> <!-- Main Area --> <div class="container "> <div class="row mt-4"> <div class="col-sm-8"> <h1>Welcome to the responsive CMS</h1> <?php global $cn; if(isset($_GET["searchbutton"])){ $search = $_GET["search"]; $sql = "SELECT * FROM post where datetime LIKE :search OR title LIKE :search OR post LIKE :search OR category LIKE :search OR author LIKE :search"; $stmt = $cn->prepare($sql); $stmt->bindValue(':search','%'.$search.'%'); $stmt->execute(); } else{ $getidfromurl = $_GET["id"]; if(!isset($getidfromurl)) { $_SESSION["ErrorMessage"] ="Bad Request !"; redirect("blog.php"); } $sql = "SELECT * FROM post WHERE id='$getidfromurl'"; $stmt = $cn->query($sql); } while ($DataRow = $stmt->fetch()) { $postid = $DataRow["id"]; $posttitle = $DataRow["title"]; $datetime = $DataRow["datetime"]; $admin = $DataRow["author"]; $image = $DataRow["image"]; $post = $DataRow["post"]; $category = $DataRow["category"]; ?> <div class="card"> <img src="upload/<?php echo $image; ?>" style="max-height: 450px;" class="img-fluid card-img-top"/> <div class="card-body"> <h4 class="card-title"><?php echo htmlentities($posttitle); ?></h4> <small>Written By <?php echo $admin?> On <?php echo htmlentities($datetime) ?></small> <span style="float: right;" class="badge badge-dark">Comments 20</span> <hr> <p class="card-text"> <?php echo htmlentities($post); ?></p> </div> <?php /////While Loop Bracket } ?> <hr> </div> <div class="card mb-3"> <div class="card-header"> <h5 class=".Fieldinfo"> Comment your thought on this post</h5> </div> <div class="card-body"> <div class="form-group"> <div class="input-group"> <div class="input-group-prepend"> <span class="input-group-text"><i class="fas fa-user"></i></span> </div> <input class="form-control" type="text" name="commentername" placeholder="Enter Your Name" > </div> </div> <div class="form-group"> <div class="input-group"> <div class="input-group-prepend"> <span class="input-group-text"><i class="fas fa-envelope"></i></span> </div> <input class="form-control" type="email" name="commenteremail" placeholder="Enter Your Email" required> </div> </div> <div class="form-group"> <textarea class="form-control" name="comments" rows="8" cols="80"> </textarea> </div> <div class=""> /////Problem with this button <button type="submit" name="Submit">Publish</button> </div> </div> </div> <br> <!--- Main Area End --> </div> <!---- Side Are Start --> <div class="col-sm-3" style="min-height:40px; background:green;"> </div> <!--- Side Area End --> </div> </div> <br> <!---Footer Start--> <footer class="bg-dark text-white"> <div class="container"> <div class="row" > <div class="col"> <p class="lead text-center">Theme By | Ehsan Nawaz | <span id="year"></span> © ----ALL Right Reserved.</p> </div> </div> </div> </footer> <div style="height: 10px; background: #27aae1;"></div> <!--footer End--> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.min.js" integrity="sha384-VHvPCCyXqtD5DqJeNxl2dtTyhF78xXNXdkwX1CZeRusQfRKp+tA7hAShOK/B/fQ2" crossorigin="anonymous"></script> <script> $('#year').text(new Date().getFullYear()); </script> </body> </html> When i press publish button my code can't be execute i also try the var_dump method on this code but can't find the error Please seniors help me Quote Link to comment https://forums.phpfreaks.com/topic/314697-when-i-press-publish-button-code-cant-run/ Share on other sites More sharing options...
benanamen Posted April 14, 2022 Share Posted April 14, 2022 (edited) You close out the form for the search but have no form opening for the rest. You are also missing the method attribute for the one you do have. Edited April 14, 2022 by benanamen Quote Link to comment https://forums.phpfreaks.com/topic/314697-when-i-press-publish-button-code-cant-run/#findComment-1595314 Share on other sites More sharing options...
mac_gyver Posted April 14, 2022 Share Posted April 14, 2022 where in your markup are the <form ...> </form> tags for the post method form? Quote Link to comment https://forums.phpfreaks.com/topic/314697-when-i-press-publish-button-code-cant-run/#findComment-1595315 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.