C-1
03-25-2004, 10:02 PM
Well I'm making a file submiter and I already have that done. Though now im working on the edit commands. I have the deleting part but the edit part just doesnt seem to work.
And this editing thing is beginning to anoy me. First i forgot a very simple piece of the code and it changed everyone in the mysql table to "Test". And then i finally get almost everything to work and the file fanishes from the folder it was in. So now i come to ask you if one of you can edit my code so it will edit and rename the file for me as well.
This is what I want it to do :
[list=1]
Submit the variables from the files mysqltable to the page so that all the boxes are already filled with the previous info
Submit the new info back into the mysql table
Rename the file since at the beginning of each file it shows which type of filetype it is. that variable is $filen
And last but no least i want it to display warnings if the edit was not successful
[/list=1]
Here's the code (i didnt add the rename part of the code yet but the command to rename is
rename("oldfilename.txt", "newfilename.txt"); And if my code is ****, which it probably is then just change it and make ur own.
Here's the code:
<?php
mysql_connect("localhost", "", "");
mysql_select_db("");
?>
<?
$_ = "_";
$dbname = "";
$connect = mysql_connect("localhost", "", "") or
die("Failed to connect");
$query1 = "SELECT title, author, moreinfo, filetype, filen FROM
testfiles WHERE id = {$_GET['id']}";
$result = mysql_db_query($dbname,$query1,$connect) or
die("Failed SELECT FILE query:<br /><br />\n$query");
list($title,$author,$moreinfo,$filetype,$filen) =
mysql_fetch_row($result);
if(!isset($upload)) {
$upload = "";
}
switch($upload) {
default:
include "/home/borntowo/public_html/cclan/filesubmit1.php";
echo "
<div align=\"center\">
<center>
<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"
style=\"border-collapse: collapse\" width=\"400\">
<tr>
<td height=\"25\">
<p align=\"center\"><font size=\"2\"><b>Edit
File</b></font></td>
</tr>
<tr>
<td><font size=\"2\">The same restrictions apply here as
they did on the File Submit Page.</font>
</ul>
<form method=\"POST\"
action=\"fileedit.php?upload=doupload&id=$id\"
enctype=\"multipart/form-data\">
<table border=\"0\" width=\"100%\" cellspacing=\"0\"
cellpadding=\"0\">
<tr>
<td width=\"100%\">Title:</td>
<td width=\"100%\"> <input value=\"$title\"
maxLength=\"50\" name=\"title\" size=\"20\"></td>
</tr>
<tr>
<td width=\"100%\">Author:</td>
<td width=\"100%\"><input value=\"$author\"
maxLength=\"50\" name=\"author\" size=\"20\"></td>
</tr>
<tr>
<td width=\"100%\">Description:</td>
<td width=\"100%\"> <textarea name=\"moreinfo\" cols=\"50\"
rows=\"5\">$moreinfo</textarea></td>
</tr>
<tr>
<td width=\"100%\">Choose FileType</td>
<td width=\"100%\"><SELECT name=\"filetype\">
<OPTION value=\"$filetype\">$filen</OPTION>
<OPTION value=\"1\">Shoppers</OPTION>
<OPTION value=\"2\">Forts</OPTION>
<OPTION value=\"3\">JetPackRace</OPTION>
<OPTION value=\"4\">Ropers</OPTION>
<OPTION value=\"5\">T17</OPTION>
<OPTION value=\"6\">RopeRace</OPTION>
<OPTION value=\"7\">BattleRace</OPTION>
<OPTION value=\"8\">Wascar</OPTION>
<OPTION value=\"9\">BnG</OPTION>
<OPTION value=\"10\">KingsArmy</OPTION>
<OPTION value=\"11\">Misc</OPTION>
<OPTION value=\"12\">BoomRaces</OPTION>
<OPTION value=\"13\">FlyShoppers</OPTION>
<OPTION value=\"14\">FilePacks</OPTION>
<OPTION value=\"15\">Programs</OPTION>
<OPTION value=\"16\">Graves</OPTION>
<OPTION value=\"17\">Flags</OPTION>
<OPTION value=\"18\">Schemes</OPTION>
</SELECT>
</td>
</tr>
<tr>
<td width=\"100%\">Confirm File Type (for important
reasons..</td>
<td width=\"100%\"><SELECT name=\"filen\">
<OPTION value=\"$filen\">$filen</OPTION>
<OPTION value=\"Shoppers\">Shoppers</OPTION>
<OPTION value=\"Forts\">Forts</OPTION>
<OPTION value=\"JetPackRace\">JetPackRace</OPTION>
<OPTION value=\"Ropers\">Ropers</OPTION>
<OPTION value=\"T17\">T17</OPTION>
<OPTION value=\"RopeRace\">RopeRace</OPTION>
<OPTION value=\"BattleRace\">BattleRace</OPTION>
<OPTION value=\"Wascar\">Wascar</OPTION>
<OPTION value=\"BnG\">BnG</OPTION>
<OPTION value=\"KingsArmy\">KingsArmy</OPTION>
<OPTION value=\"Misc\">Misc</OPTION>
<OPTION value=\"BoomRaces\">BoomRaces</OPTION>
<OPTION value=\"FlyShoppers\">FlyShoppers</OPTION>
<OPTION value=\"FilePacks\">FilePacks</OPTION>
<OPTION value=\"Programs\">Programs</OPTION>
<OPTION value=\"Graves\">Graves</OPTION>
<OPTION value=\"Flags\">Flags</OPTION>
<OPTION value=\"Schemes\">Schemes</OPTION>
</SELECT>
</td>
</tr>
</table>
<br>
<button name=\"submit\" type=\"submit\">Edit</button>
</p>
</form>
<p>
</td>
</tr>
</tr>
</table>
</center>
</div>
";
break;
?>
<?
case "doupload":
if ($moreinfo == "") {
$endresult = "<font size=\"2\">No description!</font>";
}else{
if ($filen == "") {
$endresult = "<font size=\"2\">No File Type Was Selected!
<br>(remember you must select it twice in two different
spots)</font>";
}else{
if ($filetype == "") {
$endresult = "<font size=\"2\">No File Type Was Selected!
<br>(remember you must select it twice in two different
spots)</font>";
}else{
if ($author == "") {
$endresult = "<font size=\"2\">No author!</font>";
}else{
if ($title == "") {
$endresult = "<font size=\"2\">No title!</font>";
}else{
$endresult = "<H1>File Edit Successful!</H1>";
$query = "UPDATE testfiles SET title='$title',
author='$author', moreinfo='$moreinfo',filetype='$filetype',
filen='$filen' WHERE id = {$_GET['id']}";
mysql_db_query($dbname,$query,$connect)
or die("Failed UPDATE query<br /><br />\n$query");
}
}
}
}
}
echo "
<div align=\"center\">
<center>
<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"
style=\"border-collapse: collapse\" bordercolor=\"#111111\"
width=\"400\">
<tr>
<td bgcolor=\"#5E6A7B\" height=\"25\">
</td>
</tr>
<tr>
<td bgcolor=\"#818EA0\">
<center> $endresult </center>
</td>
</tr>
<tr>
<td bgcolor=\"#5E6A7B\" height=\"25\">
<p align=\"center\"><font size=\"1\">
<br>
</td>
</tr>
</table>
</center>
</div>
";
break;
}
?>
And this editing thing is beginning to anoy me. First i forgot a very simple piece of the code and it changed everyone in the mysql table to "Test". And then i finally get almost everything to work and the file fanishes from the folder it was in. So now i come to ask you if one of you can edit my code so it will edit and rename the file for me as well.
This is what I want it to do :
[list=1]
Submit the variables from the files mysqltable to the page so that all the boxes are already filled with the previous info
Submit the new info back into the mysql table
Rename the file since at the beginning of each file it shows which type of filetype it is. that variable is $filen
And last but no least i want it to display warnings if the edit was not successful
[/list=1]
Here's the code (i didnt add the rename part of the code yet but the command to rename is
rename("oldfilename.txt", "newfilename.txt"); And if my code is ****, which it probably is then just change it and make ur own.
Here's the code:
<?php
mysql_connect("localhost", "", "");
mysql_select_db("");
?>
<?
$_ = "_";
$dbname = "";
$connect = mysql_connect("localhost", "", "") or
die("Failed to connect");
$query1 = "SELECT title, author, moreinfo, filetype, filen FROM
testfiles WHERE id = {$_GET['id']}";
$result = mysql_db_query($dbname,$query1,$connect) or
die("Failed SELECT FILE query:<br /><br />\n$query");
list($title,$author,$moreinfo,$filetype,$filen) =
mysql_fetch_row($result);
if(!isset($upload)) {
$upload = "";
}
switch($upload) {
default:
include "/home/borntowo/public_html/cclan/filesubmit1.php";
echo "
<div align=\"center\">
<center>
<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"
style=\"border-collapse: collapse\" width=\"400\">
<tr>
<td height=\"25\">
<p align=\"center\"><font size=\"2\"><b>Edit
File</b></font></td>
</tr>
<tr>
<td><font size=\"2\">The same restrictions apply here as
they did on the File Submit Page.</font>
</ul>
<form method=\"POST\"
action=\"fileedit.php?upload=doupload&id=$id\"
enctype=\"multipart/form-data\">
<table border=\"0\" width=\"100%\" cellspacing=\"0\"
cellpadding=\"0\">
<tr>
<td width=\"100%\">Title:</td>
<td width=\"100%\"> <input value=\"$title\"
maxLength=\"50\" name=\"title\" size=\"20\"></td>
</tr>
<tr>
<td width=\"100%\">Author:</td>
<td width=\"100%\"><input value=\"$author\"
maxLength=\"50\" name=\"author\" size=\"20\"></td>
</tr>
<tr>
<td width=\"100%\">Description:</td>
<td width=\"100%\"> <textarea name=\"moreinfo\" cols=\"50\"
rows=\"5\">$moreinfo</textarea></td>
</tr>
<tr>
<td width=\"100%\">Choose FileType</td>
<td width=\"100%\"><SELECT name=\"filetype\">
<OPTION value=\"$filetype\">$filen</OPTION>
<OPTION value=\"1\">Shoppers</OPTION>
<OPTION value=\"2\">Forts</OPTION>
<OPTION value=\"3\">JetPackRace</OPTION>
<OPTION value=\"4\">Ropers</OPTION>
<OPTION value=\"5\">T17</OPTION>
<OPTION value=\"6\">RopeRace</OPTION>
<OPTION value=\"7\">BattleRace</OPTION>
<OPTION value=\"8\">Wascar</OPTION>
<OPTION value=\"9\">BnG</OPTION>
<OPTION value=\"10\">KingsArmy</OPTION>
<OPTION value=\"11\">Misc</OPTION>
<OPTION value=\"12\">BoomRaces</OPTION>
<OPTION value=\"13\">FlyShoppers</OPTION>
<OPTION value=\"14\">FilePacks</OPTION>
<OPTION value=\"15\">Programs</OPTION>
<OPTION value=\"16\">Graves</OPTION>
<OPTION value=\"17\">Flags</OPTION>
<OPTION value=\"18\">Schemes</OPTION>
</SELECT>
</td>
</tr>
<tr>
<td width=\"100%\">Confirm File Type (for important
reasons..</td>
<td width=\"100%\"><SELECT name=\"filen\">
<OPTION value=\"$filen\">$filen</OPTION>
<OPTION value=\"Shoppers\">Shoppers</OPTION>
<OPTION value=\"Forts\">Forts</OPTION>
<OPTION value=\"JetPackRace\">JetPackRace</OPTION>
<OPTION value=\"Ropers\">Ropers</OPTION>
<OPTION value=\"T17\">T17</OPTION>
<OPTION value=\"RopeRace\">RopeRace</OPTION>
<OPTION value=\"BattleRace\">BattleRace</OPTION>
<OPTION value=\"Wascar\">Wascar</OPTION>
<OPTION value=\"BnG\">BnG</OPTION>
<OPTION value=\"KingsArmy\">KingsArmy</OPTION>
<OPTION value=\"Misc\">Misc</OPTION>
<OPTION value=\"BoomRaces\">BoomRaces</OPTION>
<OPTION value=\"FlyShoppers\">FlyShoppers</OPTION>
<OPTION value=\"FilePacks\">FilePacks</OPTION>
<OPTION value=\"Programs\">Programs</OPTION>
<OPTION value=\"Graves\">Graves</OPTION>
<OPTION value=\"Flags\">Flags</OPTION>
<OPTION value=\"Schemes\">Schemes</OPTION>
</SELECT>
</td>
</tr>
</table>
<br>
<button name=\"submit\" type=\"submit\">Edit</button>
</p>
</form>
<p>
</td>
</tr>
</tr>
</table>
</center>
</div>
";
break;
?>
<?
case "doupload":
if ($moreinfo == "") {
$endresult = "<font size=\"2\">No description!</font>";
}else{
if ($filen == "") {
$endresult = "<font size=\"2\">No File Type Was Selected!
<br>(remember you must select it twice in two different
spots)</font>";
}else{
if ($filetype == "") {
$endresult = "<font size=\"2\">No File Type Was Selected!
<br>(remember you must select it twice in two different
spots)</font>";
}else{
if ($author == "") {
$endresult = "<font size=\"2\">No author!</font>";
}else{
if ($title == "") {
$endresult = "<font size=\"2\">No title!</font>";
}else{
$endresult = "<H1>File Edit Successful!</H1>";
$query = "UPDATE testfiles SET title='$title',
author='$author', moreinfo='$moreinfo',filetype='$filetype',
filen='$filen' WHERE id = {$_GET['id']}";
mysql_db_query($dbname,$query,$connect)
or die("Failed UPDATE query<br /><br />\n$query");
}
}
}
}
}
echo "
<div align=\"center\">
<center>
<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"
style=\"border-collapse: collapse\" bordercolor=\"#111111\"
width=\"400\">
<tr>
<td bgcolor=\"#5E6A7B\" height=\"25\">
</td>
</tr>
<tr>
<td bgcolor=\"#818EA0\">
<center> $endresult </center>
</td>
</tr>
<tr>
<td bgcolor=\"#5E6A7B\" height=\"25\">
<p align=\"center\"><font size=\"1\">
<br>
</td>
</tr>
</table>
</center>
</div>
";
break;
}
?>