Guest User

Untitled

a guest
Jan 16th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Upload</title>
  4. </head>
  5. <body>
  6.  
  7. <form action="action.php" method="post">
  8.  
  9. <fieldset class="first">
  10. Name:
  11. <input type="text" name="author" />
  12. Heading:
  13. <input type="text" name="heading" />
  14.  
  15. Text:
  16. <textarea type="text" name="thecontent"> </textarea>
  17. </fieldset>
  18.  
  19.  
  20. <fieldset>
  21. <input type="submit"/>
  22. </fieldset>
  23. </form>
  24.  
  25.  
  26.  
  27. </body>
  28. </html>
  29.  
  30. <html>
  31. <head>
  32.  
  33. <title>Send!</title>
  34. </head>
  35.  
  36. <body>
  37.  
  38. <?php
  39.  
  40. ini_set('display_errors', 1); error_reporting(E_ALL);
  41.  
  42. $link = mysql_connect('localhost','name','pasword')
  43. or die ("Unable to connect");
  44.  
  45. $mydb = mysql_select_db('the_database',$link)
  46. or die ("No database found");
  47.  
  48. $author = $_POST['author'];
  49. $heading = $_POST['heading'];
  50. $thecontent = $_POST['thecontent'];
  51.  
  52. $mysql_query="INSERT INTO articles ('heading', 'author', 'content')
  53. VALUES ('$heading','$author','$thecontent')" or die(mysql_error());
  54.  
  55. echo "This was send: $author $heading $thecontent <br> ";
  56.  
  57.  
  58. mysql_close()
  59.  
  60. ?>
  61.  
  62. </body>
  63. </html>
  64.  
  65. <html>
  66. <head>
  67.  
  68. <title>Send!</title>
  69. </head>
  70.  
  71. <body>
  72.  
  73. <?php
  74.  
  75. ini_set('display_errors', 1); error_reporting(E_ALL);
  76. $DB_HOST = 'localhost';
  77. $DB_USER = '**';
  78. $DB_PASS = '***';
  79. $DB_NAME = '***';
  80. @ $db = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);
  81. if (mysqli_connect_errno()) {
  82. echo 'Error.';
  83. exit();
  84. }
  85.  
  86. $author = $_POST['author'];
  87. $heading = $_POST['heading'];
  88. $thecontent = $_POST['thecontent'];
  89.  
  90. $query = 'INSERT INTO articles ('heading', 'author', 'content')
  91. VALUES ('$heading','$author','$thecontent')';
  92.  
  93. $result = $db->query($query);
  94. if ($result) {
  95. echo $db->affected_rows."This was added.";
  96. }
  97. else {
  98. echo "somethings gone very wrong.";
  99. }
  100.  
  101. $db->close();
  102.  
  103.  
  104.  
  105.  
  106. ?>
  107.  
  108. </body>
  109. </html>
  110.  
  111. $mysql_query="INSERT INTO articles ('heading', 'author', 'content')
  112.  VALUES ('$heading','$author','$thecontent')";
  113. mysql_query($mysql_query);
  114. //required to run the query..
  115.  
  116. And mysql_close(); // missing :p
Add Comment
Please, Sign In to add comment