CREATE TABLE `post` ( `postid` INT(11) NOT NULL AUTO_INCREMENT, `post_text` VARCHAR(200) NOT NULL, `date_time` datetime NOT NULL, PRIMARY KEY(`postid`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
<?php //MySQLi Procedural if (!$conn) { } ?>
<!DOCTYPE html> <html lang = "en"> <head> <meta charset = "UTF-8" name = "viewport" content = "width=device-width, initial-scale=1"/> </head> <body> <div id = "post_form"> <form> </form> <br> </div> </body> <script type = "text/javascript"> $(document).ready(function(){ displayResult(); /* ADDING POST */ $('#add_post').on('click', function(){ if($('#post').val() == ""){ alert('Please enter something first'); }else{ $post = $('#post').val(); $.ajax({ type: "POST", url: "add_post.php", data: { post: $post, }, success: function(){ displayResult(); } }); } }); /***** *****/ }); function displayResult(){ $.ajax({ url: 'add_post.php', type: 'POST', async: false, data:{ res: 1 }, success: function(response){ $('#result').html(response); } }); } </script> </html>
<?php include ('conn.php'); mysqli_query($conn,"insert into `post` (`post_text`, `date_time`) values ('$post', NOW())") or die(mysqli_error()); } ?> <?php ?> <?php ?> <div> Post: <?php echo $row['post_text']; ?> </div> <br> <?php } } ?>
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.