-
Notifications
You must be signed in to change notification settings - Fork 0
/
add.php
151 lines (127 loc) · 5 KB
/
add.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php
require("connect-db.php");
require("spotify-db.php");
session_start();
$user_id = $_SESSION['user_id'];
if ($user_id === NULL){
echo "<p>You are currently logged out with limited functionality</p>";
}else{
echo "<p>You are currently logged in as $user_id</p>";
}
function getRandomStringRand($length = 22)
{
$stringSpace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$stringLength = strlen($stringSpace);
$randomString = '';
for ($i = 0; $i < $length; $i ++) {
$randomString = $randomString . $stringSpace[rand(0, $stringLength - 1)];
}
return $randomString;
}
if ($_SERVER['REQUEST_METHOD']=='POST')
{
if (!empty($_POST['actionBtn']) && ($_POST['actionBtn'] == "Add Track"))
{
$song_id = getRandomStringRand();
$album_id = getRandomStringRand();
$artist_id = getRandomStringRand();
addTrack_Song($song_id, $_POST['title'], $_POST['duration'], $artist_id);
addTrack_Album($album_id, $_POST['album_name'], $_POST['album_type'], $_POST['num_of_tracks'], $_POST['release_year'], $artist_id);
addTrack_AlbumName_ArtistID($artist_id,$_POST['album_name'],$album_id);
addTrack_Artist($artist_id, $_POST['name'], $_POST['country']);
addTrack_SongTitle_AlbumID($_POST['title'],$album_id,$song_id);
addTrack_SongTitle_ArtistID($_POST['title'],$artist_id,$album_id);
addTrack_Song_Genre($song_id, $_POST['genre']);
addTrack_Song_Language($song_id, $_POST['language']);
echo "<br>song_id added successfully! song_id = " . $song_id;
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- 2. include meta tag to ensure proper rendering and touch zooming -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="your name">
<meta name="description" content="include some description about your page">
<title>Hoo's Listening</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link rel="icon" type="image/png" href="http://www.cs.virginia.edu/~up3f/cs4750/images/db-icon.png" />
</head>
<body>
<div class="container">
<h1>Hoo's Listening</h1>
<form name="mainForm" action="add.php" method="post">
<div class="row mb-3 mx-3">
Track Title:
<input type="text" class="form-control" name="title"
value="<?php echo $track_to_update[0]['title']; ?>"
/>
</div>
<div class="row mb-3 mx-3">
Release Year:
<input type="text" class="form-control" name="release_year"
value="<?php if ($track_to_update!=NULL) echo $track_to_update[0]['release_year']; ?>"
/>
</div>
<div class="row mb-3 mx-3">
Duration:
<input type="text" class="form-control" name="duration"
value="<?php if ($track_to_update!=NULL) echo $track_to_update[0]['duration']; ?>"
/>
</div>
<div class="row mb-3 mx-3">
Album Name:
<input type="text" class="form-control" name="album_name"
value="<?php if ($track_to_update!=NULL) echo $track_to_update[0]['album_name']; ?>"
/>
</div>
<div class="row mb-3 mx-3">
Album Type:
<input type="text" class="form-control" name="album_type"
value="<?php if ($track_to_update!=NULL) echo $track_to_update[0]['album_type']; ?>"
/>
</div>
<div class="row mb-3 mx-3">
Number of Tracks in Album:
<input type="text" class="form-control" name="num_of_tracks"
value="<?php if ($track_to_update!=NULL) echo $track_to_update[0]['num_of_tracks']; ?>"
/>
</div>
<div class="row mb-3 mx-3">
Language:
<input type="text" class="form-control" name="language"
value="<?php if ($track_to_update!=NULL) echo $track_to_update[0]['language']; ?>"
/>
</div>
<div class="row mb-3 mx-3">
Genre:
<input type="text" class="form-control" name="genre"
value="<?php if ($track_to_update!=NULL) echo $track_to_update[0]['genre']; ?>"
/>
</div>
<div class="row mb-3 mx-3">
Artist Name:
<input type="text" class="form-control" name="name"
value="<?php if ($track_to_update!=NULL) echo $track_to_update[0]['name']; ?>"
/>
</div>
<div class="row mb-3 mx-3">
Artist Country:
<input type="text" class="form-control" name="country"
value="<?php if ($track_to_update!=NULL) echo $track_to_update[0]['country']; ?>"
/>
</div>
<div class="row mb-3 mx-3">
<input type="submit" class="btn btn-primary" name="actionBtn" value="Add Track" title="click to insert song" />
</div>
</form>
<div class="row mb-3 mx-3">
<a href="index.php">
<input type="submit" class="btn btn-primary" name="actionBtn" value="Go to Home Page" title="go back to home page" />
</a>
</div>
</div>
</body>
</html>