Jump to content

Ehsan_collboy

Members
  • Posts

    19
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Ehsan_collboy's Achievements

Member

Member (2/5)

0

Reputation

  1. i want to print the $admin name on xxx
  2. <small class="text-muted">Category:: <?php echo $category;?> Written By <span class="text-dark"><a href="profile.php?username=<?php echo $admin;?>"></a></span> On <?php echo htmlentities($datetime) ?></small> When i apply <a></a> tag on <?php echo $admin ?> on admin variable it show nothing when i check on browser inspect mode admin name show but front view nothing show it only show Written by When i remove the <a> tag $admin variable work fine and show the data on browser
  3. I told you you are Amazing Thanks You Soooooooooooooooooooooooooooooooooooooooooooo Much
  4. Sorry from me for late reply (You guys amazing .. No debit ..) This code is redirect .php <?php include_once("include/db.php"); ?> <?php function redirect($Newlocation){ header("Location:".$Newlocation); exit; } function checkusername($Username){ global $cn; $sql = "SELECT username FROM admin WHERE username=:username"; $stmt = $cn->prepare($sql); $stmt->bindValue(":username",$Username); $stmt->execute(); $Result = $stmt->rowCount(); if($Result>0) { return $stmt->fetch(); }else { return false; } function Login_sucess($Username,$Password){ global $cn; $sql = "SELECT * FROM admin WHERE username=:username AND password=:password LIMIT 1"; $stmt = $cn->prepare($sql); $stmt->bindValue(":username",$Username); $stmt->bindValue(":password",$Password); $stmt->execute(); $Result = $stmt->rowCount(); if($Result==1) { return $Found_Account = $stmt->fetch(); }else { return null; } } } ?> And this code is login.php where i see the error <?php require_once("include/db.php"); require_once("include/session.php"); require_once("include/redirect.php"); ?> <?php if(isset($_POST["login"])) { $Username = $_POST["username"]; $Password = $_POST["password"]; if(empty($Username)||empty($Password)){ $_SESSION["ErrorMessage"] = "All fields must bee fills"; redirect("login.php"); } /////Checking username and password from database else { $login =Login_sucess($Username,$Password); if($login){ $_SESSION["successMessage"] = "Login Sucess "; redirect("login.php"); }else { $_SESSION["ErrorMessage"] = "Username/Password Incorrect Please Try Again...!"; redirect("login.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> Welcome To the BummerStyle </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"> </div> </div> </nav> <div style="height: 10px; background: #27aae1;"></div> <!---navbar End--> <header class="bg-dark text-white py-3"> <div class="container "> <div class="row"> </div> </div> </header> <!-- Main Area Start ---> <section class="container py-2 mb-4"> <div class="row"> <div class="offset-sm-3 col-sm-6" style="min-height:500px;"> <br><br><br> <?php echo ErrorMessage(); echo SuccessMessage(); ?> <div class="card bg-secondary text-light"> <div class="card-header"> <h4 style="text-align: center;">Welcome Back!</h4> </div> <div class="card-body bg-dark"> <form method="POST" action="login.php"> <div class="form-group"> <label for="username" style="color: rgb(251, 174, 44);">Username:</label> <div class="input-group mb-3"> <div class="input-group-prepend"> <span class="input-group-text text-white bg-info"><i class="fas fa-user"></i></span> </div> <input type="text" class="form-control" name="username" id="username"> </div> </div> <div class="form-group"> <label for="password" style="color: rgb(251, 174, 44);">Password:</label> <div class="input-group mb-3"> <div class="input-group-prepend"> <span class="input-group-text text-white bg-info"><i class="fas fa-lock"></i></span> </div> <input type="password" class="form-control" name="password" id="password"> </div> </div> <input type="submit" name="login" class="btn btn-info btn-block" value="Login"> </form> </div> </div> </div> </div> </section> <!--- Main Area End ---> <!---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> &copy; ----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> Please check my code and highlight my problem
  5. First sorry for my wrong type code posting I use visual studio code for coding and Firefox (in private mode) for viewing in(private mode) Firefox doesn't store the cache every thing is working fine instead of this code any other solution for this i will try on my code or i try your suggestion code .instead of my code
  6. i create this function if login_sucess and save this redirect.php file function Login_sucess($Username,$Password){ global $cn; $sql = "SELECT * FROM admin WHERE username=:username AND password=:password LIMIT 1"; $stmt = $cn->prepare($sql); $stmt->bindValue(":username",$Username); $stmt->bindValue(":password",$Password); $stmt->execute(); $Result = $stmt->rowCount(); if($Result==1) { return $Found_Account = $stmt->fetch(); }else { return null; } } and then i call this function in login.php <?php require_once("include/db.php"); require_once("include/session.php"); require_once("include/redirect.php"); ?> <?php if(isset($_POST["login"])) { $Username = $_POST["username"]; $Password = $_POST["password"]; if(empty($Username)||empty($Password)){ $_SESSION["ErrorMessage"] = "All fields must bee fills"; redirect("login.php"); } else { $login =Login_sucess($Username,$Password);//// line 19 if($login){ $_SESSION["successMessage"] = "Login Sucess "; redirect("login.php"); }else { $_SESSION["ErrorMessage"] = "Username/Password Incorrect Please Try Again...!"; redirect("login.php"); } } } ?> When i hit login button its show me this error Uncaught Error: Call to undefined function Login_sucess() in C:\xampp\htdocs\CMS\login.php:19 Stack trace: #0 {main} thrown in C:\xampp\htdocs\CMS\login.php on line 19
  7. function Login_sucess($Username,$Password){ global $cn; $sql = "SELECT * FROM admin WHERE username=:username AND password=:password LIMIT 1"; $stmt = $cn->prepare($sql); $stmt->bindValue(":username",$Username); $stmt->bindValue(":password",$Password); $stmt->execute(); $Result = $stmt->rowCount(); if($Result==1) { return $Found_Account = $stmt->fetch(); }else { return null; } } I create this function for userlogin when user press the login button here the other code if(isset($_POST["login"])) { $Username = $_POST["username"]; $Password = $_POST["password"]; if(empty($Username)||empty($Password)){ $_SESSION["ErrorMessage"] = "All fields must bee fills"; redirect("login.php"); } /////Checking username and password from database else { $login =Login_sucess($Username,$Password); if($login){ $_SESSION["successMessage"] = "Login Sucess "; redirect("login.php"); }else { $_SESSION["ErrorMessage"] = "Username/Password Incorrect Please Try Again...!"; redirect("login.php"); } } } Uncaught Error: Call to undefined function Login_sucess() in C:\xampp\htdocs\CMS\login.php:19 Stack trace: #0 {main} thrown in C:\xampp\htdocs\CMS\login.php on line 19
  8. function Login_sucess($Username,$Password){ global $cn; $sql = "SELECT * FROM admin WHERE username=:username AND password=:password LIMIT 1"; $stmt = $cn->prepare($sql); $stmt->bindValue(":username",$Username); $stmt->bindValue(":password",$Password); $stmt->execute(); $Result = $stmt->rowCount(); if($Result==1) { return $Found_Account = $stmt->fetch(); }else { return null; } } Here is my Calling Function else { $login =Login_sucess($Username,$Password); if($login){ $_SESSION["successMessage"] = "Login Sucess "; redirect("login.php"); }else { $_SESSION["ErrorMessage"] = "Username/Password Incorrect Please Try Again...!"; redirect("login.php"); } } When i execute my code thy show me the error Uncaught Error: Call to undefined function Login_sucess() in C:\xampp\htdocs\CMS\login.php:19 Stack trace: #0 {main} thrown in C:\xampp\htdocs\CMS\login.php on line 19 line 19 is $login = login_sucess($username,$password)
  9. I have made this code in such a way that if any username is already present in the database then it will show error but this code is not working but added to the database..You are better than me and have big Experience That's why I call you Senior
  10. function checkusername($Username){ global $cn; $sql = "SELECT username FROM admin WHERE username=:username"; $stmt = $cn->prepare($sql); $stmt->bindValue(":username",$Username); $stmt->execute(); $Result = $stmt->rowCount(); if($Result==1) { return true; }else { return false; } } hi my code all code is running well this function i made checking the username in the database when i execute the code this code didn't check the username in the database its insert the data into the database with out checking the duplicate entry
  11. i set my datetime in varcahar type and post_id is set as index type in database
  12. $sql = "INSERT INTO comments(name,datetime,email,comments,approvedby,status,post_id)"; $sql .= "VALUES(:name,:email,:datetime,:comments,'Pending','OFF',:post_id)"; $stmt = $cn->prepare($sql); $stmt->bindValue(":name",$name); $stmt->bindValue(":email",$email); $stmt->bindValue(":comments",$comments); error in this line $stmt->bindValue(":post_id",$searchqueryparameters); $sucess = $stmt->execute(); if($sucess) { $_SESSION["successMessage"] = "Comments has been post and Waiting for Aprovel"; redirect("fullpost.php?id=$searchqueryparameters"); }else { $_SESSION["ErrorMessage"] = "System Error Try Again...!"; redirect("fullpost.php?id=searchqueryparameters"); } hi seniors my code is working file till when i didn't add the post_id when i add my post_id variable in the code thy show me the error and also i join the two tables in the database post_id is coming from the post tabel Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in C:\xampp\htdocs\CMS\Fullpost.php:49 Stack trace: #0 C:\xampp\htdocs\CMS\Fullpost.php(49): PDOStatement->execute() #1 {main} thrown in C:\xampp\htdocs\CMS\Fullpost.php on line 49
  13. <?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> &copy; ----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
  14. Thanks Man for Checking my code The first problem is when a new user come to the code he want to register on code but registration can't proceed and the second problem is friends post can't show on index page
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.