diff options
| author | Zach DeCook <zachdecook@gmail.com> | 2018-11-04 15:37:47 -0500 |
|---|---|---|
| committer | Zach DeCook <zachdecook@gmail.com> | 2018-11-04 15:37:47 -0500 |
| commit | 1ae91210f38f0599702973a3e1664b3598fc52ae (patch) | |
| tree | 22d358816717fc46d9cd559935307daa0e1cd698 /page.php | |
| parent | fe627f58c7064d2c6aa1b59cbe3c9114d1aaba6a (diff) | |
| download | prosongsa-1ae91210f38f0599702973a3e1664b3598fc52ae.tar.gz | |
* Don't show form if song is already fav'd
Diffstat (limited to 'page.php')
| -rw-r--r-- | page.php | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/page.php b/page.php index ba30fe1..8a2805d 100644 --- a/page.php +++ b/page.php @@ -189,11 +189,25 @@ function load_song( $number, $transp = 0 ) function renderFavorite( $number ) { $number = str_replace( "'", "", $number ); - return "<form method='post'>" - . "<input type='hidden' name='song' value='$number'>" - . "<input name='name' placeholder='your name' value=" . ($_COOKIE['name'] ?? '') . ">" - . "<input type='submit' value='Add to Favorites' class='btn btn-F'>" - . "</form>"; + $name = str_replace("'", "", $_COOKIE['name'] ?? '' ); + if ( $name ) + { + $file_db = new SQLite3('db/favs.db'); + $favd = $file_db->querySingle( "SELECT name from favorites where name = '$name' AND song = '$number'"); + } + if ( $favd ) + { + $favd = strip_tags( $favd ); + return "Song in favorites for $favd"; + } + else + { + return "<form method='post'>" + . "<input type='hidden' name='song' value='$number'>" + . "<input name='name' placeholder='your name' value=" . ($name ?? '') . ">" + . "<input type='submit' value='Add to Favorites' class='btn btn-F'>" + . "</form>"; + } } function renderEasyTransp( $transp, $num, $songKeys = array() ) |
