Benden
maging ang maganda mamatay
So I made this because I'm always forgetting names of songs. Anyways I wanted to release it here
UPDATE: I've added a style to it and made some tiny changes to the code. This is version 1.2.0
index.php
add.php
config.php
style.css
Database
It comes with my music as Im using it.
I hope you like it. It was my first real php thing
UPDATE: I've added a style to it and made some tiny changes to the code. This is version 1.2.0
index.php
PHP:
<?php
include_once ('config.php');
$page = $_GET['page'];
switch($page)
{
case 'add':
include 'add.php';
break;
} ;
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div class="music"><?php $query="select * from music";
$rt=mysql_query($query);
echo mysql_error();
while($info=mysql_fetch_array($rt)){ echo "<br><center>$info[Title]</center><b>$info[band]</b></table><hr>";} ?></div>
<p /><div class="addBox">Click <a href="index.php?page=add">here</a> to add a song</div>
</body>
</html>
add.php
PHP:
<?php
include 'config.php';
if ($_POST['register'])
{
//get form data
$Title = addslashes(strip_tags($_POST['Title']));
$band = addslashes(strip_tags($_POST['band']));
if (!$Title||!$band)
echo "To add a song, please fill in all fields.";
else
{
//check if the song name is already taken
$check = mysql_query("SELECT * FROM music WHERE Title='$Title'");
if (mysql_num_rows($check)>=1)
echo "This song has already been added.";
else
{
{
//register into database
$register = mysql_query("INSERT INTO music VALUES ('','$Title','$band')");
header( 'Location: index.php' ) ;
}
}
}
}
else
{
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<center>
<form action='add.php' method='POST'>
Title:<br />
<input type='text' name='Title'><p />
Band/artist:<br />
<input type='text' name='band'><p />
<input type='submit' name='register' value='add'>
</form>
</center>
</body>
</html>
<?php
}
?>
config.php
PHP:
<?php
//connect to database
$error = "Problem connecting";
mysql_connect('server','username','password') or die($error);
mysql_select_db('DataBase') or die($error);
?>
PHP:
body {
background-image:url('bg.png');
background-repeat:repeat-x;
}
.addBox {
padding:15px;
padding-bottom:4px;
padding-top:4px;
margin-left: auto;
margin-right: auto;
width:600;
color:#FFFFFF;
font-family:verdana;
font-size:20px;
text-align:center;
font-weight:bold;
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#8C8D86), to(#000000));
box-shadow: 2px 2px 6px rgba(0,0,0,0.6);
border:1px solid black;
border-radius: 1em;
}
a:link {color:#FFFFFF;}
a:visited {color:#FFFFFF;}
a:hover {color:#FFFFFF;}
a:active {color:#FFFFFF;}
.music {
padding:15px;
padding-bottom:4px;
padding-top:4px;
margin-left: auto;
margin-right: auto;
height:auto;
width:90%;
color:#FFFFFF;
font-family:verdana;
font-size:15px;
text-align:center;
font-weight:bold;
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#8C8D86), to(#000000));
box-shadow: 2px 2px 6px rgba(0,0,0,0.6);
border:1px solid black;
border-radius: 1em;
}
.addMusic{
padding:15px;
padding-bottom:4px;
padding-top:4px;
margin-left: auto;
margin-right: auto;
height:auto;
width:90%;
color:#FFFFFF;
font-family:verdana;
font-size:15px;
text-align:center;
font-weight:bold;
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#8C8D86), to(#000000));
box-shadow: 2px 2px 6px rgba(0,0,0,0.6);
border:1px solid black;
border-radius: 1em;
}
Database
PHP:
-- phpMyAdmin SQL Dump
-- version 3.1.3.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jun 08, 2011 at 04:31 PM
-- Server version: 5.1.33
-- PHP Version: 5.2.9
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- Database: `music`
--
-- --------------------------------------------------------
--
-- Table structure for table `music`
--
CREATE TABLE IF NOT EXISTS `music` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`Title` text NOT NULL,
`band` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ;
--
-- Dumping data for table `music`
--
INSERT INTO `music` (`id`, `Title`, `band`) VALUES
(1, 'For the first time', 'The script'),
(2, 'Man that cannot be moved', 'The Script'),
(3, 'Whos that chick', 'Rihanna'),
(4, 'Written in the stars', 'Tinie Tempah'),
(7, 'I just want to dance', 'Rihanna'),
(8, 'Detroit City', 'Eminem'),
(9, ' Breakeven (Falling To Pieces)', 'The Script'),
(10, 'Who Says', 'Selena Gomez & The Sence'),
(11, 'Please don\\''t go', 'Mike Posner'),
(12, 'The Lazy Song', 'Bruno Mars'),
(13, 'Last Resort', 'Papa Roach'),
(14, 'Hey Soul Sister', 'Train');
I hope you like it. It was my first real php thing