This concept based on post comments to display on below page. its like feedback comments form method. users visit our website to give the feedback or comments to directly show on other users coding using on php and mysqli just post the comments to store in database to fetch on directly.
Database
Create blow type table database connect file using on Mysqli connection through the site
CREATE TABLE `comments` (
`email` VARCHAR( 25 ) NOT NULL ,
`comments` VARCHAR( 25 ) NOT NULL
)
`email` VARCHAR( 25 ) NOT NULL ,
`comments` VARCHAR( 25 ) NOT NULL
)
PHP
<?php
$Random_code=rand ();
if(isset($_POST['submit'])!="")
{
$username=$_POST['email'];
$commends=$_POST['message'];
$code=$_POST['code'];
$random=$_POST['random'];
if($code=="$random")
{
$insert=$db->query("insert into comments(email,comments) values('$username','$commends')");
if($insert)
{
echo "<script> alert('Thanks to comment on my post') </script>";
}
}
else
{
echo "<script> alert('confirmation code incorrect try agani') </script>";
}
}
?>
$Random_code=rand ();
if(isset($_POST['submit'])!="")
{
$username=$_POST['email'];
$commends=$_POST['message'];
$code=$_POST['code'];
$random=$_POST['random'];
if($code=="$random")
{
$insert=$db->query("insert into comments(email,comments) values('$username','$commends')");
if($insert)
{
echo "<script> alert('Thanks to comment on my post') </script>";
}
}
else
{
echo "<script> alert('confirmation code incorrect try agani') </script>";
}
}
?>
CSS
<style type="text/css">
body
{
margin:0;
padding:0;
}
.login
{
width:900px;
height:0 auto;
margin:0 auto;
-moz-box-shadow:0px 0px 1px 1px #999;
-webkit-box-shadow:0px 0px 1px 1px #999;
}
.login form
{
width:400px;
height:500px;
margin:0 auto;
}
.mostlikers-top
{
height:100px;
background-color:#f2f2f2; }
.mostlikers-bottom
{
height:50px;
background-color:#f2f2f2;
}
input[type]
{
border: 1px solid #ccc;
border-radius: 3px;
box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
width:300px;
min-height: 28px;
padding: 4px 20px 4px 8px;
font-size: 18px;
-moz-transition: all .2s linear;
-webkit-transition: all .2s linear;
transition: all .2s linear;
}
.clear
{
padding-top:20px;
}
.comment_box
{
margin:0 auto;
box-shadow: inset 0 1px 15px rgba(0,0,0,0.1);
width:600px; height:100px;
}
</style>
body
{
margin:0;
padding:0;
}
.login
{
width:900px;
height:0 auto;
margin:0 auto;
-moz-box-shadow:0px 0px 1px 1px #999;
-webkit-box-shadow:0px 0px 1px 1px #999;
}
.login form
{
width:400px;
height:500px;
margin:0 auto;
}
.mostlikers-top
{
height:100px;
background-color:#f2f2f2; }
.mostlikers-bottom
{
height:50px;
background-color:#f2f2f2;
}
input[type]
{
border: 1px solid #ccc;
border-radius: 3px;
box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
width:300px;
min-height: 28px;
padding: 4px 20px 4px 8px;
font-size: 18px;
-moz-transition: all .2s linear;
-webkit-transition: all .2s linear;
transition: all .2s linear;
}
.clear
{
padding-top:20px;
}
.comment_box
{
margin:0 auto;
box-shadow: inset 0 1px 15px rgba(0,0,0,0.1);
width:600px; height:100px;
}
</style>
HTML
<body>
<div class="mostlikers-top">
<a href="http://karthickinfotech.blogspot.in/">
<img name="mostlikers" style="border:none;" src="demo.png" title="mostlikers" alt="mostlikers" /></a>
</div>
<div class="login"><br />
<form class="form-wrapper" method="post">
<h1>Comment form using php</h1>
<p><strong>Email</strong><br />
<input type="email" name="email" required="required" placeholder="compose your new Twit" ></p>
<p><strong>Comments</strong><br />
<textarea rows="5" cols="40" required="required" placeholder="Post your commends here" name="message">
</textarea></p>
<p>Enter this below code <span style="font-size:24px; color:#F00;"> <?php echo $Random_code;
?></span>
<input type="hidden" name="random" value="<?php echo $Random_code; ?>" />
<br />
<input type="text" name="code" placeholder="code" >
</p>
<p><input type="submit" name="submit" value="Post comments" /></p>
</form>
<?php
$view_comments=$db->query("select * from comments");
while($comm=mysqli_fetch_object($view_comments))
{
?>
<div class="comment_box">
<div style="float:left;"><img src="user.png" width="80" height="80" /></div>
<div>
<?php echo $comm->email; ?>
<hr />
"<?php echo $comm->comments; ?>"
</div>
</div>
<div class="clear"></div>
<?php } ?>
</div>
<div class="mostlikers-bottom">
<h3><a href="karthickinfotech.blogspot.in/p/chat.html">Click more mostlikers Demos</a></h3></div>
</body>
<div class="mostlikers-top">
<a href="http://karthickinfotech.blogspot.in/">
<img name="mostlikers" style="border:none;" src="demo.png" title="mostlikers" alt="mostlikers" /></a>
</div>
<div class="login"><br />
<form class="form-wrapper" method="post">
<h1>Comment form using php</h1>
<p><strong>Email</strong><br />
<input type="email" name="email" required="required" placeholder="compose your new Twit" ></p>
<p><strong>Comments</strong><br />
<textarea rows="5" cols="40" required="required" placeholder="Post your commends here" name="message">
</textarea></p>
<p>Enter this below code <span style="font-size:24px; color:#F00;"> <?php echo $Random_code;
?></span>
<input type="hidden" name="random" value="<?php echo $Random_code; ?>" />
<br />
<input type="text" name="code" placeholder="code" >
</p>
<p><input type="submit" name="submit" value="Post comments" /></p>
</form>
<?php
$view_comments=$db->query("select * from comments");
while($comm=mysqli_fetch_object($view_comments))
{
?>
<div class="comment_box">
<div style="float:left;"><img src="user.png" width="80" height="80" /></div>
<div>
<?php echo $comm->email; ?>
<hr />
"<?php echo $comm->comments; ?>"
</div>
</div>
<div class="clear"></div>
<?php } ?>
</div>
<div class="mostlikers-bottom">
<h3><a href="karthickinfotech.blogspot.in/p/chat.html">Click more mostlikers Demos</a></h3></div>
</body>
No comments:
Post a Comment