Advertisement
Guest User

Untitled

a guest
Nov 6th, 2018
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3. <center>
  4. <head>
  5. <title> Page Title</title>
  6. </head>
  7.  
  8. <body>
  9. <?php
  10. // Username: bossmodeteehee
  11. // Password: bossmodeteehee
  12.  
  13. // Username: jeffreyquade
  14. // Password: jeffreyquade
  15.  
  16. $servername = "localhost";
  17. $username = "Jeffrey_Quade";
  18. $password = "aPassword";
  19.  
  20. // trying to connect to the server
  21. try {
  22. $conn = new PDO("mysql:host=$servername;dbname=jquadecr_HomeWork5", $username, $password);
  23. // set the PDO error mode to exception
  24. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  25. echo "Connected successfully";
  26. }
  27. catch(PDOException $e)
  28. {
  29. echo "Connection failed: " . $e->getMessage();
  30. }
  31. ?>
  32.  
  33. <!-- select category -->
  34. <form action=" Homework5.2.php" method="post">
  35. ONE:<input type="radio" name="ONE" value="ONE"> <br>
  36. TWO:<input type="radio" name="ONE" value="TWO"> <br>
  37. THREE:<input type="radio" name="ONE" value="THREE"> <br>
  38.  
  39. <!-- setting the link -->
  40. Link to Image: <input type="text" name="Link"> <br>
  41.  
  42. <!-- setting the category -->
  43. Description: <input type="text" name="Description"> <br>
  44.  
  45. <input type="submit" name="submit" value="submit">
  46. </form>
  47.  
  48. <?php
  49. $cat = $_POST["ONE"]; // setting cat to the chosen category
  50. $img = $_POST["Link"]; //same for the image
  51. $dsc = $_POST["Description"]; // and description
  52.  
  53. // putting it all into the table
  54. $sql = 'INSERT INTO "Pictures" (Category, Link, Description) VALUES ($cat, $img, $dsc)';
  55. ?>
  56. </body>
  57. </center>
  58. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement