How to make awesome stylish comment input box in PHP language for my website.


In this tutorial we are creating comment input box for websites into PHP scripting language. We are storing comments directly into MySQL database so website admin can assess them using PhpMyAdmin control panel. This forms are designed with custom style CSS code that makes the input files more big and gives hover effects. So here is the complete step by step tutorial for Create PHP comment box using MySQL database and Store entered comments into DB.
android-project-download-code-button

How to Create PHP comment box using MySQL database and Store entered comments into DB.

Code for comment.php file.
 <!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Comment Box</title>
<style>

body{
 margin:0px;
 font-family:Baskerville, 'Palatino Linotype', Palatino, 'Century Schoolbook L', 'Times New Roman', serif;
 }

input[type=text], select {
 width: 100%;
 border-radius: 5px;
 margin: 7px 0;
 border: 1px solid #ccc;
 padding: 14px 18px; 
 display: inline-block;
 box-sizing: border-box;
}

input[type=submit]:hover {
 background-color: #00a7d1;
}

textarea, select {
 width: 100%;
 border-radius: 5px;
 margin: 7px 0;
 border: 1px solid #ccc;
 padding: 14px 18px; 
 display: inline-block;
 box-sizing: border-box;
}

input[type=submit] {
 width: 100%;
 border: none;
 color: white;
 padding: 14px 20px;
 background-color: #01c9fb;
 margin: 8px 0;
 cursor: pointer;
 border-radius: 4px;
 
}

</style>

</head>
<body>
<table bgcolor="#f2f2f2" style="padding:50px" align="center">
<form action="" method="post">
<tr>
<td> Name : </td><td><input type="text" name="name"></td>
</tr>
<tr>
<td> Email : </td><td><input type="text" name="email"></td>
</tr>
<tr>
<td> Website : </td><td><input type="text" name="website"></td>
</tr>
<tr>
<td> Comment : </td><td><textarea name="comment" rows="6" cols="50"></textarea></td>
</tr>
<tr>
<td><input type="submit" name="submit"></td></tr>

</form>
</table>



<?php
if(isset($_POST["submit"]))
{
 
 //Including dbconfig file.
include 'dbconfig.php';
 
$name = $_POST["name"];
$email = $_POST["email"];
$website = $_POST["website"];
$comment = $_POST["comment"];


mysql_query("INSERT INTO comment_table (name,email,website,comment) VALUES ('$name','$email','$website','$comment')"); 

echo '<center> Comment Successfully Submitted </center>';

}

 ?>

</body>
</html>
Code for dbconfig.php file.
 <?php

 //This script is designed by Android-Examples.com
//Define your host here.
$hostname = "localhost";

//Define your database username here.
$username = "root";

//Define your database password here.
$password = "";

//Define your database name here.
$dbname = "test";

 $conn = mysql_connect($hostname, $username, $password);
 
 if (!$conn)
 
 {
 
 die('Could not connect: ' . mysql_error());
 
 }
 
 mysql_select_db($dbname, $conn);

 //This script is designed by Android-Examples.com

?>
Screenshot:
Create PHP comment box using MySQL database and Store entered comments into DB

Click here to download Create PHP comment box using MySQL database and Store entered comments into DB project with source code + MySQL database included.

Comments

  1. Wow, cool post. I'd like to write like this too - taking time and real hard work to make a great article... but I put things off too much and never seem to get started. Thanks though. Learn PHP

    ReplyDelete

Post a Comment

Popular posts from this blog

How to add image, header, and footer in PDF | PHP FPDF Tutorial Final

log in with facebook , paypal, php to pdf