Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <head>
- <meta charset="utf-8">
- <link href="css/bootstrap.min.css"rel="style">
- <script src="js/bootstrap.min.js"></script>
- <title>Add DVD</title>
- </head>
- <?php
- require 'database.php';
- if( !empty($_POST)){
- $titleError = null;
- $dateError = null;
- $countryError = null;
- $durationError = null;
- $title = $_POST['title'];
- $date = $_POST['release_date'];
- $country = $_POST['origin_country'];
- $duration = $_POST['duration'];
- $valid = true;
- if(empty($title)){
- $titleError = "Please enter a title";
- $valid = false;
- }
- if(empty($date)){
- $dateError = "Please enter a date";
- $valid = false;
- }
- if(empty($country)){
- $counrtyError = "Please enter a country";
- $valid = false;
- }
- if(empty($duration)){
- $durationError = "Please enter a duration";
- $valid = false;
- }
- if($valid){
- $pdo = Database::connect();
- $pdo -> setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
- $sql = "INSERT INTO dvd(title,release_date, origin_country, duration) values(?,?,?,?)";
- $q = $pdo->prepare($sql);
- $q->execute(array($title,$date, $country, $duration));
- Database::disconnect();
- header("Location: dvd.php");
- }
- }
- ?>
- <body>
- <div class="container">
- <div class="span10 offset1">
- <div class="row">
- <h3>Add a new DVD</h3>
- </div>
- <!-- voeg een dvd toe -->
- <!-- title -->
- <form class="form-horizontal" action="createdvd.php" method="post">
- <div class="control-group <?php echo !empty($titleError)?'error':'';?>">
- <label class="control-label">Title</label>
- <div class="controls">
- <input name="title" type="text" placeholder="title" value="<?php echo !empty($titleError)):?>"></input>
- <span class="help-inline"><?php echo $titleError;?></span>
- <?php endif; ?>
- </div>
- </div>
- <!--
- <label>Description</label>
- <input name="description"type="textarea"placeholder="put here a description"></input>
- -->
- <!-- release date -->
- <form class="form-horizontal" action="createdvd.php" method="post">
- <div class="control-group <?php echo !empty($dateError)?'error':'';?>">
- <label class="control-label">Release_date</label>
- <div class="controls">
- <input name= "releasedate" type="text"placeholder="ex. 01/01/1990" value="<?php echo !empty($dateError)):?>"></input>
- <span class="help-inline"><?php echo $dateError;?></span>
- <?php endif; ?>
- </div>
- </div>
- <!-- origin country -->
- <form class="form-horizontal" action="createdvd.php" method="post">
- <div class="control-group <?php echo !empty($countryError)?'error':'';?>">
- <label>Origin country</label>
- <div class="controls">
- <input name="origin-country"type="text" placeholder="origin country" value="<?php echo !empty($countryError)):?>"></input>
- <span class="help-inline"><?php echo $countryError;?></span>
- <?php endif; ?>
- </div>
- </div>
- <!-- duration -->
- <form class="form-horizontal" action="createdvd.php" method="post">
- <div class="control-group <?php echo !empty($durationError)?'error':'';?>">
- <label>Duration</label>
- <div class="controls">
- <input name="duration"type="text"placeholder="ex 120"value="<?php echo !empty($durationError)):?>"></input>
- <span class="help-inline"><?php echo $durationError;?></span>
- <?php endif; ?>
- </div>
- </div>
- <!-- genre
- <label>Genre</label>
- <input name="genre1"type="checkbox">Action</input>
- <input name="genre2"type="checkbox">Adventure</input>
- <input name="genre3"type="checkbox">Comedy</input>
- <input name="genre4"type="checkbox">Drama</input>
- <input name="genre5"type="checkbox">Fantasy</input>
- <input name="genre6"type="checkbox">Horror</input>
- <input name="genre7"type="checkbox">Romantic</input>
- <input name="genre8"type="checkbox">Science Fiction</input>
- -->
- <div class="form-actions">
- <button type="submit" class="btn btn-success">Create</button>
- <a class="btn" href="dvd.php">Back</a>
- </div>
- </form>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement