php - submit and show records without reloading page -
i have form, submit data in table , show them on same page. reloads page.
i want submit , show data without reloading page. have read many ajax scripts. confused .
can 1 please?
<form action="viewblog.php" method="post"> <h3 class="contact_title">leave comment</h3> <div class="contact_form"> <div class="row"> <div class="large-4 columns"> <input type="text" name="name" placeholder="name" /> </div> <div class="large-12 columns"> <textarea cols="10" rows="15" name="comment" placeholder="comment"></textarea> </div> <div class="small-4 columns"> <input type="submit" name="submit" class="button right" value="add comment" /> </div> </div> </div> </form> <?php if(isset($_post["submit"])) { require"connection.php"; extract($_post); extract($_request); mysql_query("insert comment values('','',now(),'$name','$comment')") or die (mysql_error()); echo"comment inserted succesfully !"; } ?> <?php include('connection.php'); extract($_request); $sql = "select * enteries;"; $result = mysql_query($sql); while($row1=mysql_fetch_array($result)) { extract($row1); ?> <div class="comments"> <ol class="comment_list"> <!--comment item--> <li class="com_item"> <div class="com_main"> <div class="com_content"> <div class="com_meta"> <span class="user_name"><a href="#"><? php echo $name; ?></a></span> <span class="com_date"><?php echo date("d js f y ", strtotime($dateposted)) ?> </span> </div> <p class="com_text"><?php echo $comment; ?> </p> </div> </div> </li> </ol> </div> <?php } ?>
php executes @ server side, directly writing php , html combined won't make call without reload.
you need javascript
ajax call. can use jquery or javascript or other library.
this link teach basics ajax.
Comments
Post a Comment