PDA

View Full Version : File Submiter Editor


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\">
&nbsp;</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;
}
?>

C-1
03-27-2004, 06:49 PM
80 frickin views and no one helps..

raf
03-28-2004, 11:13 AM
I'm not intrested in starting an argument here so don't bother posting an angry reply.

The situation is that you have a problem and you would like us to help you. But your post shouts : hey! somebody feels like rewriting my code and adding some extra's ! I also don't see any intrest in learning to code in your post.

I only help people that give a clear problem description and want to learn how to solve a coding-problem. Reading 'just doesn't seem to work' is already enough to make me skip to the next thread.

I'm not here to write your code. Specialy not if it is such basic formbuilding and formprocessing code and if you give such general descriptions about what you want. Writing that out would be boring me.

If you want help, then post about the problems you have with one specific task. Like 'How can i display a value from the db in a textbox' and you only do so after you ran a search in the php forum or after you read a basic tutorial at www.hotscripts.com or whatever. This sites isn't some sort of coding-service or an interactive tutorial for real basic codingissues.
If yu need some code without making the effort to read a few tutorials and learn how to code, then just hire a coder.

So it basically comes down to : if you want help, then you need to convince us that it's worth looking into your problem and that you first tryed to solve it yourself but that you still have problems with this and that specific task.

C-1
03-29-2004, 02:24 AM
As you can see it's already displayed. My problem was it shows the old data when it resubmits. Not the stuff you put back in. But w/e ur probably right. Delete the posts i made. I don't really care.

C-1
03-30-2004, 10:11 PM
Well not exactly that code but almost the same code i figured out the problem was that it wasnt displaying the errors. So instead of the errors being displayed it just resubmits the data i submited in the first place. But if i do fill in all the fields it works.. could sum1 find a way for those errors to work?

C-1
03-30-2004, 10:35 PM
ah nevermind. I figured out my whole problem. I had to put ($_POST['moreinfo'] == "") on my errors..