Hello, I had a different thread, but figured this is more suitable in here, but at the same time it's different, but almost the same.. okay, on with the script..
<style type="text/css">
BODY {
margin-bottom:0;
margin-top:0;
margin-right:0;
margin-left:0;
background-color:black;
scrollbar-face-color:black;
scrollbar-highlight-color:black;
scrollbar-3dlight-color:gray;
scrollbar-darkshadow-color:black;
scrollbar-shadow-color: black;
scrollbar-arrow-color:gray;
scrollbar-track-color:black;
}
<style type="text/css">
.submit { width: 74px; height: 34px; display:block; }
.image1 { background:url(/bschedule/bsadmin/images/uploadtoepk.gif); width: 154px; height: 34px; display:block; }
.image2 { background:url(/bschedule/bsadmin/images/emailclear.gif); width: 74px; height: 34px; display:block; }
</style>
<style>
textarea{
background-image:url(/bschedule/bsadmin/images/epktextback.jpg); background-attachment: fixed;
color:000000; }
</style>
<style type="text/css">
input {background-image:url(/bschedule/bsadmin/images/epkfieldback.jpg)}
</style>
<style type="text/css">
SELECT {
{background-image:url(/bschedule/bsadmin/images/epkfieldback.jpg)
}
</style>
<title>EPK Creator</title><body bgcolor="#000000" text="#FFFFFF" link="#CCCC00" vlink="#CCCC00" alink="#CCCC00" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="36">
<table width="100%" border="0" background="/bschedule/bsadmin/images/headerback.gif" cellspacing="0" cellpadding="0">
<tr>
<td height="60" width="6%"><img src="/bschedule/bsadmin/images/logosmall.gif" width="181" height="58"></td>
<td height="60" width="94%">
<div align="right"><font face="Arial, Helvetica, sans-serif"><b><font color="#CCCC00">News
Entry </font></b></font></div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="11"> <?php include("header.php") ?></td>
</tr>
<tr>
<td height="21">
<div align="center">
<table width="100%" border="0">
<tr bgcolor="#666666">
<td colspan="4"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">So
far you have the following MP3's attached to your EPK (Limit 5)
</font></td>
</tr>
<tr>
<td colspan="4"> <font color="#FFFFFF" face="Arial, Helvetica, sans-serif" size="2">Song
1: <?php
// read in the connection settings
require("dbconnection.txt");
// connect to the RDBMS
$db = mysql_connect("$site","$user","$pass")
or die_now("<h2>Could not connect to database server</h2><p>Check passwords and sockets</p>");
// select the database
mysql_select_db("$database",$db)
or die_now("<h2>Could not select database $database</h2><p>Check database name</p>");
$link = "SELECT * FROM epk";
$result = mysql_query($link);
if (!$result) {
die('Could not query:' . mysql_error());
}
$row = mysql_fetch_assoc($result);
echo '<font size="2" color="#CC0000" face="Arial, Helvetica, sans-serif"><a href="'.$row["songlink"].'">' . $row["songtitle"] . '</a></font>'; ?>
Song 2:<?php $link = "SELECT * FROM epk"; echo '<font size="2" color="#CC0000" face="Arial, Helvetica, sans-serif"><a href="'.$row["songlinktwo"].'">' . $row["songtitletwo"] . '</a></font>'; ?>
Song 3:<?php $link = "SELECT * FROM epk"; echo '<font size="2" color="#CC0000" face="Arial, Helvetica, sans-serif"><a href="'.$row["songlinkthree"].'">' . $row["songtitlethree"] . '</a></font>'; ?>
Song 4:<?php $link = "SELECT * FROM epk"; echo '<font size="2" color="#CC0000" face="Arial, Helvetica, sans-serif"><a href="'.$row["songlinkfour"].'">' . $row["songtitlefour"] . '</a></font>'; ?>
Song 5:<?php $link = "SELECT * FROM epk"; echo '<font size="2" color="#CC0000" face="Arial, Helvetica, sans-serif"><a href="'.$row["songlinkfive"].'">' . $row["songtitlefive"] . '</a></font>'; ?></font></td>
</tr>
</table>
<font color="#000000">.</font><br>
<font size="3" face="Arial, Helvetica, sans-serif"><b>Use this form to
upload your first MP3</b></font><font size="2" face="Arial, Helvetica, sans-serif"><br>
<font color="#CCCCCC">File MUST be in MP3 format. File must be no more
than 2MB in size.</font></font><br>
<br>
</div>
<div align="center"></div>
<div align="center"><font color="#CCCCCC" size="2" face="Arial, Helvetica, sans-serif">
</font><font color="#CCCCCC" size="2" face="Arial, Helvetica, sans-serif">
<?php
function do_upload() {
// Create an array containing all valid upload file types for this script
$allowed_types = array(
"audio/mpeg" => "mp3",
// Add more types here if you like
);
// Check to see if the file type is in the allowed types array
if(!array_key_exists($_FILES['userfile']['type'], $allowed_types)) {
die("Invalid file type.");
}
// Set the maximum uploadable file size => 51200 = 50kb
$maxfilesize = 207204800;
// Is the file larger than it is allowed to be?
if($_FILES['userfile']['size'] > $maxfilesize) {
die("File too large");
}
// Where will the file be uploaded to?
$uploaddir = $_SERVER['DOCUMENT_ROOT'] . "/bschedule/bsadmin/music/";
// What is the files temporary name?
$file = $_FILES['userfile']['tmp_name'];
// What is the files actual name?
$filename = $_FILES['userfile']['name'];
// Does this file already exist on the server?
if(file_exists($uploaddir . $filename)) {
die("A flyer with that file name is already in the folder. Please either delete the flyer or rename it and upload it again. Use the back button to re-upload or try again.");
} else {
// This file does not already exist, so copy it.
copy($file, $uploaddir.$filename) or die("Could not copy file.");
}
// end of upload script
// read in the connection settings
require("dbconnection.txt");
// connect to the RDBMS
$db = mysql_connect("$site","$user","$pass")
or die_now("<h2>Could not connect to database server</h2><p>Check passwords and sockets</p>");
// select the database
mysql_select_db("$database",$db)
or die_now("<h2>Could not select database $database</h2><p>Check database name</p>");
$sqlQ = "UPDATE schedule SET songlink = '/bschedule/bsadmin/music/".$filename."' WHERE id = '".$_POST["id"]."';";
$sqlR = mysql_query($sqlQ)or die("Could not do a mysql query. Reason why: ".mysql_error());
}
?>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if($_POST['action'] == "do_upload") {
do_upload();
}
$songtitle = htmlentities($_POST['songtitle']);
$songlink = htmlentities($_POST['songlink']);
$id = htmlentities($_POST['id']);
$link = "UPDATE epk SET songtitle='$songtitle', songlink = '/bschedule/bsadmin/music/".$filename."' WHERE id='$id'";
$res = mysql_query($link) or die(mysql_error());
if ($res)
die("News Updated Succesfully.<br />Choose from the menu to continue.");
}
else
{
$id = preg_replace("/'\/<>\"/","",$_GET['id']);
if (empty($id))
die("Invalid ID");
$link = "SELECT * FROM epk WHERE id='$id'";
$res = mysql_query($link) or die(mysql_error());
$r = mysql_fetch_assoc($res);
echo '
<html>
<head><title>EPK Creator</title></head>
<body>
<form action="" method="POST">
Song Title: <input type="text" name="songtitle" value="' . $r['songtitle'] . '">
Song File: <input type="file" name="userfile" value="' . $r['songlink'] . '"><br />
<input type="hidden" name="id" value="' . $r['id'] . '">
<table width="39%" border="0">
<tr>
<td>
<div align="center">
<input type=submit name="submit" class="submit image1" value="">
</div>
</td>
<td>
<div align="center">
<input type="reset" name="submit2" class="submit image2" value="">
</div>
</td>
</tr>
</table>
</form>
</body>
</html>';
}
?>
</font> </div>
</td>
</tr>
</table>
I figure the problem goes between lines 164-168, but I'm not sure...
Heres what it's NOT doing. It's not uploading the mp3 and putting the link in the database.
Here is what it IS doing. It is puting the title in the database and part of the mp3 link... but only the path and not the file. This is reading from a previous page (for the ID for the database) which is why tats important so that it will enter in the right ID.
If anyone can help get the upload and insertion part going right, I will be your best friend for eternity and hold my glass up high with a toast, as this has been a headache for 2 weeks now and I feel like bashing my skull into the PC.
Thanks immensly
Peredy