Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title></title>
  6. </head>
  7.  
  8. <body>
  9. <form action="share.php" method="post">
  10. <input type="text" name="posttitle"></input>
  11. <br/>
  12.  
  13. <textarea name="postcontent"></textarea>
  14. <br/>
  15.  
  16. <input type="submit" value="insert"></input>
  17. </form>
  18. </body>
  19. </html>
  20.  
  21. <?php
  22. $con = mysqli_connect("localhost", "root", "", "mugg_website");
  23.  
  24. if(!$con){
  25. echo 'database not connected';
  26. }
  27.  
  28. $articleName = mysqli_real_escape_string($con, $_POST['posttitle']);
  29. $articleContent = mysqli_real_escape_string($con, $_POST['postcontent']);
  30.  
  31. $sql = "INSERT INTO post (post_title, post_content) VALUES ('$articleName', '$articleContent')";
  32.  
  33. if(!mysqli_query($con,$sql)){
  34. echo 'notpublished';
  35. }else{
  36. echo 'published';
  37. }
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement