php - Display records from database -


i'm trying display information stored in mysql comments table input i'm having issues that. input named entercomment inserts data db , want redirect showcomment input.

html:

form action='takedata.php' method='post'>             <input type='text' id='entercomment' name='entercomment' width='400px' placeholder='write comment...'>             <input type='submit' id='combuton' name='combuton' value='comment!'>             <input type='text' id='showcomment' name='showcomment'>         </form> 

php:

<?php include "mysql.php"; ?>  <?php     if (isset($_post['combuton'])){         $entercomment = strip_tags($_post['entercomment']);             if($entercomment){                 $addcomment = mysql_query("insert comments(comment) values('$entercomment')");                 if($addcomment==1)                     //insert showcomment input;             }     } ?> 

try this, , use mysqli instead of mysql

include "dbconnect.php";  if (isset($_post['combuton'])){         $entercomment = strip_tags($_post['entercomment']);         if($entercomment){             $addcomment = mysqli_query($conn, "insert comments(comment) values('$entercomment')");             if($addcomment) {                 $sql = "select comment comments order id desc limit 1";                 $result = mysqli_query($conn, $sql);                 while($row = $result->fetch_assoc()) { ?>                     <input type="text" value="<?php echo $row['comment']; ?>">                 <?php }             }          }  } 

your form

<form action='' method='post'>             <input type='text' id='entercomment' name='entercomment' width='400px' placeholder='write comment...'>             <input type='submit' id='combuton' name='combuton' value='comment!'>             <?php if(!isset($_post['combuton'])) { ?>                  <input type="text" value="">             <?php } ?>         </form> 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -