linkenpark51471
New Member
- Messages
- 27
- Reaction score
- 0
- Points
- 0
why dosn't this work? its to upload an mp3 and with the information you input into the text box's and puts the name of the mp3 into the table on the database
Code:
<?
$con = mysql_connect("localhost","rabble","rabblel");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("rabble", $con);
session_start();
if(!isset($_SESSION["id"])){
header("location:index.php");
}
// start of uploading script
$target_path = "upload/";
$song = $target_path . basename( $_FILES['uploadedfile']['name']);
$person = $_SESSION["id"];
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "Sorry there was an error with your song, try another";
}
// end of uploading script
$person = $_SESSION["id"];
if(isset($_POST["file"]) && isset($_POST["name"]))
{
$person = $_SESSION["id"];
$file = mysql_real_escape_string(stripslashes($_FILE["file"]));
$name = mysql_real_escape_string(stripslashes($_POST["name"]));
$artist = mysql_real_escape_string(stripslashes($_POST["artist"]));
$type = mysql_real_escape_string(stripslashes($_POST["type"]));
$query = "INSERT INTO music (file, name, artist, genre, person)
VALUES('$file', '$name', '$artist', '$type', '$person')";
$sql=$query;
if (!mysql_query($sql))
{
die('Error: ' . mysql_error());
}
echo "Your song has been uploaded!";
}
mysql_close($con)
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Music Uploader</title>
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>
<body>
<h1>Upload a song!</h1>
every time one of your songs reaches 5 downloads you get paid!
Song File
<br>
<form enctype="multipart/form-data" action="musicuploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
<h3>Song File:</h3> <input name="file" type="file" /><br />
<br>
Song Name
<br>
<input type="text" name="name" size="25">
<br>
Artist Name
<br>
<input type="text" name="artist" size="25">
<br>
Type of music (rock, rap, country)
<br>
<input type="text" name="type" size="25">
<br>
<br>
<input type="submit" value="Upload Song">
</form>
</body>
</html>