Backend for songs.zachdecook.com
Diffstat (limited to 'index.php')
| -rwxr-xr-x | index.php | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -4,6 +4,18 @@ if ( isset( $_GET['theme'] ) ){ $theme = $_GET['theme']; setcookie( 'theme', $theme, time()+60*60*24*30 ); } +if ($_POST['song'] && $_POST['name']) +{ + $song = str_replace( "'", "", $_POST['song'] ); + $name = str_replace( "'", "", $_POST['name'] ); + $file_db = new SQLite3('db/favs.db'); + $file_db->exec( "CREATE TABLE IF NOT EXISTS favorites ( name TEXT, song TEXT );" ); + $query = "INSERT INTO favorites VALUES( '$name', '$song' );"; + $file_db->exec( $query ); + $file_db = NULL; + setcookie( 'name', $name, time()+60*60*24*356 ); + $_COOKIE['name'] = $name; +} ?> <!-- index.php contains the main html used for creating the page. |