Advertisement
Guest User

Untitled

a guest
Mar 9th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>PHP Blog</title>
  4. </head>
  5. <body>
  6. <?php
  7. require 'login.php';
  8. $db_server = mysql_connect($db_hostname, $db_username, $db_password);
  9.  
  10. if (!$db_server) die("Unable to connect to MySQL: " . mysql_error());
  11.  
  12. mysql_select_db($db_database, $db_server)
  13. or die("Unable to select database: " . mysql_error());
  14. if(isset($_POST['username']) and isset($_POST['password']))
  15. {
  16. $pass = "test";
  17. $user = "test";
  18. if($_POST['username'] == "test" and $_POST['password'] == "test")
  19. {
  20. echo <<<_END
  21. <form action="post.php" method="post"><pre>
  22. Title: <input type="text" name="title">
  23. Post: <textarea rows="5" cols="64" name="post">
  24. </textarea>
  25. <input type="submit" value="Submit">
  26. </pre></form>
  27. _END;
  28. if(isset($_POST['title']) and isset($_POST['post']))
  29. {
  30. $title = $_POST['title'];
  31. $post = $_POST['post'];
  32. $query = "INSERT INTO blog(title,post) VALUES('$title', '$post')";
  33. mysql_query($query);
  34. echo 'Succesfully posted..';
  35. echo '<a href="blog.php">Click here</a>';
  36. }
  37.  
  38. }
  39. else
  40. {
  41. echo "Wrong Password!";
  42. }
  43. }
  44. ?>
  45.  
  46. <input type="hidden" name="username"><input type="hidden" name="password">
  47.  
  48. echo <<<_END
  49. <form action="post.php" method="post"><pre>
  50. Username: <input type="text" name="username">
  51. Password: <input type="password" name="password">
  52. Title: <input type="text" name="title">
  53. Post: <textarea rows="5" cols="64" name="post">
  54. </textarea>
  55. <input type="submit" value="Submit">
  56. </pre></form>
  57. _END;
  58.  
  59. if(isset($_POST['username']) and isset($_POST['password']))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement