Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. <?php
  2. require("utils/connection.php");
  3. ?>
  4.  
  5. <!DOCTYPE html>
  6. <html>
  7. <head>
  8. <link href="css/style_sheet.css" rel='stylesheet' type='text/css'/>
  9. <link href="css/responsive_style.css" rel='stylesheet' type='text/css'/>
  10. <script src="js/helper.js"></script>
  11. <meta name="viewport" content="width=device-width, user-scalable=no"/>
  12. <title>Ships</title>
  13. </head>
  14.  
  15. <body>
  16. <ul class="topnav" id="myTopnav">
  17. <li class="firstli"></li>
  18. <li><a href="index.php">Home</a></li>
  19. <li><a href="ships.php">All Ships</a></li>
  20. <li><a href="new_ship.php">Add a Ship</a></li>
  21. <li><a href="delete_ship.php">Delete a Ship</a></li>
  22. <li id="logged_in"><?php echo $loggedIn ?></li>
  23. <li class="icon">
  24. <a href="javascript:void(0);" onclick="showResponsiveMenu()">&#9776;</a>
  25. </li>
  26. </ul>
  27.  
  28. <form action="new_ship.php" method="post" enctype="multipart/form-data">
  29. <p>Enter Ship Name:</p>
  30. <input type="text" name="name" value="">
  31.  
  32. <p>Enter Year Built:</p>
  33. <input type="number" min="1900" max="2017" step="1" name="year_built" value="">
  34.  
  35. <p>Enter Capacity:</p>
  36. <input type="number" min="1" max="200000" step="1" name="capacity" value="">
  37.  
  38. <p>Enter Ship Builder:</p>
  39. <input type="text" name="builder_name" value="">
  40.  
  41. <p>Enter Operating Company</p>
  42. <input type="text" name="operating_company" value="">
  43.  
  44. <p>Choose an image to upload</p>
  45. <input type="file" name="fileToUpload" id="fileToUpload">
  46.  
  47. <input id="submit" name="submit" type="submit" action="new_ship.php" onclick="ConfirmAdd();">
  48. <script>
  49. function ConfirmAdd(){
  50. var x = confirm("Are you sure you want to add a new ship?");
  51. if (x)
  52. return true;
  53. else
  54. return false;
  55. }
  56. </script>
  57.  
  58.  
  59.  
  60. <?php
  61. $name = htmlentities($_POST["name"]) ;
  62. $year_built = htmlentities($_POST["year_built"]) ;
  63. $capacity = htmlentities($_POST["capacity"]) ;
  64. $builder_name = htmlentities($_POST["builder_name"]) ;
  65. $operating_company = htmlentities($_POST["operating_company"]) ;
  66. $sql = "INSERT INTO ships VALUES ('$name',$year_built,$capacity,'$builder_name','$operating_company',NULL);";
  67.  
  68. $conn->query($sql);
  69. $conn->close();
  70. ?>
  71. </form>
  72.  
  73. </body>
  74. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement