Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require("utils/connection.php");
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <link href="css/style_sheet.css" rel='stylesheet' type='text/css'/>
- <link href="css/responsive_style.css" rel='stylesheet' type='text/css'/>
- <script src="js/helper.js"></script>
- <meta name="viewport" content="width=device-width, user-scalable=no"/>
- <title>Ships</title>
- </head>
- <body>
- <ul class="topnav" id="myTopnav">
- <li class="firstli"></li>
- <li><a href="index.php">Home</a></li>
- <li><a href="ships.php">All Ships</a></li>
- <li><a href="new_ship.php">Add a Ship</a></li>
- <li><a href="delete_ship.php">Delete a Ship</a></li>
- <li id="logged_in"><?php echo $loggedIn ?></li>
- <li class="icon">
- <a href="javascript:void(0);" onclick="showResponsiveMenu()">☰</a>
- </li>
- </ul>
- <form action="new_ship.php" method="post" enctype="multipart/form-data">
- <p>Enter Ship Name:</p>
- <input type="text" name="name" value="">
- <p>Enter Year Built:</p>
- <input type="number" min="1900" max="2017" step="1" name="year_built" value="">
- <p>Enter Capacity:</p>
- <input type="number" min="1" max="200000" step="1" name="capacity" value="">
- <p>Enter Ship Builder:</p>
- <input type="text" name="builder_name" value="">
- <p>Enter Operating Company</p>
- <input type="text" name="operating_company" value="">
- <p>Choose an image to upload</p>
- <input type="file" name="fileToUpload" id="fileToUpload">
- <input id="submit" name="submit" type="submit" action="new_ship.php" onclick="ConfirmAdd();">
- <script>
- function ConfirmAdd(){
- var x = confirm("Are you sure you want to add a new ship?");
- if (x)
- return true;
- else
- return false;
- }
- </script>
- <?php
- $name = htmlentities($_POST["name"]) ;
- $year_built = htmlentities($_POST["year_built"]) ;
- $capacity = htmlentities($_POST["capacity"]) ;
- $builder_name = htmlentities($_POST["builder_name"]) ;
- $operating_company = htmlentities($_POST["operating_company"]) ;
- $sql = "INSERT INTO ships VALUES ('$name',$year_built,$capacity,'$builder_name','$operating_company',NULL);";
- $conn->query($sql);
- $conn->close();
- ?>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement