Tuesday 28 May 2013

Comment Display

Output:


Index.php

<?php include
  ('connect.php');
if(isset($_POST['submit']))
{
       $comment=$_POST['comment'];
         $name=$_POST['name'];
    $email=$_POST['email'];
          $cat_image1=$_FILES['image']['name'];
      if($cat_image1!="")
      {
          $type=$_FILES['image']['type'];
      $size=$_FILES['image']['size'];
      $tempname=$_FILES['image']['tmp_name'];
      $dir="upload/".$cat_image1;
      move_uploaded_file($tempname,"$dir");
      }
      else
      {
              $cat_image1='man-icon.jpg';
      }
       
      $insert=mysql_query("insert into comment_tbl(name,email,image,size,type,location,comment,last_update) 
    values('$name','$email','$cat_image1','$size','$type','$dir','$comment',now())",$cnt) or die(mysql_error());
       if($insert)
       {
               header("location:index.php");
               }
}

   ?>
 
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Comment</title>
<script type="text/javascript" src="validate.js"></script>

<link rel="stylesheet" href="style.css" type="text/css" />

</head>

<body>

<form name="form1" method="post" action="" enctype="multipart/form-data" onsubmit="return validation();">

<div id="comment_body">

<?php 
include('connect.php'); 
$result = mysql_query("SELECT * FROM comment_tbl ORDER BY name ASC");
while($row = mysql_fetch_assoc($result))
{
    ?>
    <div id="comment_display">
   
    <div id="image"><span class="left" ><img src="upload/<?php echo $row['image'];?>" width="80" height="60px" />
    </span>
  <span class="right"><img src="img/download.jpg" width="15px" height="10px" /><?php echo $row['comment']; ?>
   <img src="img/download (2).jpg" width="15px" height="10px" /></span>
      </div>
                                               
        <div id="cmts">
            <span class="wl">
                              <p>   <?php echo $row['name']; ?></p>
                           <p><?php echo $row['email'];?></p></span>
                        <span class="wr"><?php echo $row['last_update']; ?></span>


                                                          </div>  
                                                          
</div>  <hr />
 <?php
}

?>
    </div>                              
<div id="container">
                               <h1 align="center">Add a Comment</h1>
                            <div id="content"> 
                                      <p>Name<span>*</span> </p>

<p><input type="text" name="name" value="" style="width:50%;"/>&nbsp;&nbsp;&nbsp;<em  id="name" ></em></p>

<p>Email Id<span>*</span></p>

<p><input type="email" name="email" value=""  style="width:50%;" />&nbsp;&nbsp;&nbsp;<em id="email"></em></p>


<p>Image<span>(optional)</span></p>

<p><input type="file" name="image" value="" />&nbsp;&nbsp;&nbsp;<em id="image"></em></p>

<p>Comment<span>*</span>&nbsp;&nbsp;&nbsp;<em  id="comment"></em></p>

<p><textarea name="comment" style="width:400px;height:200px;"></textarea></p>

<p style="margin-left:200px;"><input type="submit" name="submit" value="submit" /></p>
</div>

</div>
</form>
</body>
</html>


Download Code:

No comments:

Post a Comment