-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd-song.php
58 lines (49 loc) · 1.78 KB
/
add-song.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
require_once __DIR__ . '/artistquery.php';
require_once __DIR__ . '/genrequery.php';
require_once __DIR__ . '/song.php';
$aq = new ArtistQuery();
$gq = new GenreQuery();
if(isset($_POST['savebutton'])){
$title = $_POST['title'];
$artist_id = $_POST['artist'];
$genre_id = $_POST['genre'];
$price = $_POST['price'];
$song = new Song($title, $artist_id, $genre_id, $price);
$song->save();
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Song Insert</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
</head>
<body></body>
<?php if(isset($_POST['savebutton'])){ ?>
<p>The song <?php echo $song->getTitle() ?>
with an ID of <?php echo $song->getId() ?>
was inserted successfully!</p>
<a href="add-song.php">Return to Add Songs</a>
<?php }else{ ?>
<form method="post" name="songinput">
Title: <input type="text" name="title">
Artists:
<select name="artist">
<?php foreach($aq->getAll() as $artistQuery){ ?>
<option value="<?php echo $artistQuery->id ?>"><?php echo $artistQuery->artist_name ?></option>
<?php } ?>
</select>
Genre:
<select name="genre">
<?php foreach($gq->getAll() as $genreQuery){ ?>
<option value="<?php echo $genreQuery->id ?>"><?php echo $genreQuery->genre ?></option>
<?php } ?>
</select>
Price: <input type="text" name="price">
<input type="submit" value="save" name="savebutton">
</form>
<?php } ?>
<script src="/js/bootstrap.min.js"></script>
</body>
</html>