If You want to learn web design and developing from 0 to 100% then this blog is only for you Here you will be also find source code of many web design and web developing source codes. html,css,javascript,php,mysql & database tutorial, projects, source code files and many blogging tips. Best css tips etc. html css javascript amazing creations

Subscribe Us

https://affiliate.fastcomet.com/scripts/2wc9ym?a_aid=5f4ca944dcb6d&a_bid=49785082

Breaking

Post Top Ad

Wednesday, May 6, 2020

Comment System In Php with Full source code

HOW TO MAKE A COMMENT SYSTEM IN PHP MYSQL WITH DATABASE FULL SOURCE CODE AVAILALE
In this tutorial I will be teach you about A COMMENT SYSTEM IN PHP MYSQL WITH DATABASE. Very simple source code you will be find in this artical. 
I say with my whoole confidence that you will be learn all about how to make a comment system
Whoole project source code in below the some lines. You can copy and pest it in your text editor.

First I want to tell you about xampp aur wampp etc server. please start it or if you have no this software then download first.

About the project:
You will be find in this proejct that a comment box form design in html & css. In this form you will be find name, email, phonenumber and message area field aur submit button. If the user click on the submit button then these fields detail will stored in the database. In this comment form section your comment will be publish in below some lines. these system or prograame is a profeesional system. Very additional codding is used to make it more perfossional You can edit aur delate your comment also. So please read the whoole artical. We will be create a database in this prograame. Only simple steps to follow to make this programme.
please follow these steps.

1. Create an database
First step of these programe is to create a database.I suggest you to download xampp server.Start the xampp server. then type on googlechrome localhost/phpmyadmin/ after seraching this url you will be find a databse in that window. In that situation a database will be seen in chrome window. Then create a new database named by commentsystem. Make a row named by comments. Our next step is this that to select 5 columns in the row and save it. 
In first column type the column 'id', the id's value should be int(11) and autoincreament. 
In second column type the column 'name' name column's value should be varchar(255),
In third column type the column 'r_email' name column's value should be varchar(255),
In fourth column type the column 'phone' name column's value should be varchar(255),
In fiveth column type the column 'message' name column's value should be varchar(500),

2. index.php
make a file named by index.php

In this file the first action , we will be make database connection.
Type this code to make database connection

bu this code we will be link it to the database commentsection

<?php
$db_host = "localhost";
$db_user = "root";
$db_password = "";
$db_name = commentsystem";

// Create Connection
$conn = new mysqli($db_host, $db_user, $db_password, $db_name);

// Check Connection
if($conn->connect_error) {
 die("connection failed");
}
?>


after thi step we have to write some html5 basic code. I hope you already know about the codes. And you can type yourself.
I will only write the required code. If you don't know about the codes, I have type these code in my prviece posts you can read it please make view on that.



in the body section of the html5 page pest these code
make sure you have bootsrap file aur cdn link in your head section of html5 codes

<!--Start Contact Us Row-->
<div class="col-md-8">
 <!--Start Contact Us 1st Column-->
 <form action="" method="post">
  <input type="text" class="form-control" name="name" placeholder="Name"><br>
  <input type="email" class="form-control" name="email" placeholder="E-mail"><br>
  <input type="text" class="form-control" name="phone" placeholder="Subject"><br>
  <textarea class="form-control" name="message" placeholder="How can we help you?" style="height:150px;"></textarea><br>
  <input class="btn btn-primary" type="submit" value="Send" name="submit"><br><br>
  <?php if(isset($msg)) {echo $msg; } ?>
 </form>
</div> <!-- End Contact Us 1st Column-->


this is the simple bootsrap supported html5 code. It is the design of a form. It is not very professinal. it is a normal. but it is very good for out project.


3.php codes
Now we have to write php codes in this file index.php
By php code we will be store the all data from the user in this database.by This php code matter, the data which the user fill in the name, email, phone or message will be store in the database. It is very simple. If you already read my some previos posts then you will be understand very easily these codes.


<?php
 if(isset($_REQUEST['submit'])){
    // Checking for Empty Fields
    if(($_REQUEST['name'] == "") || ($_REQUEST['email'] == "") || ($_REQUEST['phone'] == "") || ($_REQUEST['message'] == "")){
      $regmsg = '<div class="alert alert-warning mt-2" role="alert"> All Fields are Required </div>';
    }else {
        $rName = $_REQUEST['name'];
        $rEmail = $_REQUEST['email'];
        $rPhone = $_REQUEST['phone'];
        $rmessage = $_REQUEST['message'];
        $sql = "INSERT INTO comments(name, r_email, phone, message) VALUES (''$rName'','$rEmail', '$rPhone', '$rmessage')";
        if($conn->query($sql) == TRUE){
          $regmsg = '<div class="alert alert-success mt-2" role="alert"> Comment Succefully Created </div>';
        } else {
          $regmsg = '<div class="alert alert-danger mt-2" role="alert"> Unable to Create Account </div>';
        }
      }
    }
  
?>


4. Comments
Now we have to nake a comment show list in the index.php file. This step is very simple. We will be complete this function in php.
In this step We have to print all the rows and columns from database in this file.
So copy these codes and pest it in in the body scetion and after the comment submit section in index.php


<?php

$sql = "SELECT * FROM comments";
$result = mysqli_query($conn,$sql);
if(mysqli_num_rows($result) > 0){

   echo '<table class="table">';
      echo "<thead>";
      echo "<tr>";
      echo "<th>id</th>";
      echo "<th>name</th>";
      echo "<th>email</th>";
      echo "<th>phone</th>";
      echo "<th>message</th>";
      echo "</tr>";
      echo "</thead>";
      echo "<tbody>";
      while($row = mysqli_fetch_assoc($result)){
        echo "<tr>"; 
        echo '<td name="id">' . $row["id"] . '</td>';
        echo '<td name="message">' . $row["name"] . '</td>';
        echo '<td name="name">' . $row["r_email"] . '</td>';
       echo '<td name="name">' . $row["phone"] . '</td>';
       echo '<td name="name">' . $row["message"] . '</td>';
     
        echo "</tr>";
      }
      echo "</tbody>";
     
      echo '</table>';
   }
 else {
  echo "0 results";
 }


?>


No comments:

Post a Comment

thanks for your comments

Post Top Ad