Problema con l'upload

maxx33

Nuovo Utente
2 Mag 2007
1
0
0
Salve a tutti,

ho un problema con uno script che mi permette di effettuare bene l'upload di più immagini (2), ma non appena provo a modificare altre variabili mysql, dal database vengono inesorabilmente cancellati i nomi delle due immagini caricate al momento dell'apertura dell'account. Immagino che il problema stia nello script che ho inserito nella sezione update...

Posto dunque il codice, sperando che qualcuno di voi possa aiutarmi...

1)

function addform($op,$vars) {
echo "<p align=center><b>Enter site information</b></p>";
echo "<form action=\"$_SERVER[PHP_SELF]?op=$op&d_op=save\" enctype=\"multipart/form-data\" method=POST>";
echo "<table border=0 align=center>";
if ($op != "update") {
echo "<tr><td>Username:</td><td><input type=text name=user_name value=\"$vars[user_name]\"></td></tr>";
echo "<tr><td>Password:</td><td><input type=password name=user_pass></td></tr>";
}
echo "<tr><td>Email:</td><td><input type=text name=user_email value=\"$vars[user_email]\"></td></tr>";
echo "<tr><td>Site name:</td><td><input name=site_name value=\"$vars[site_name]\"></td></tr>";
echo "<tr><td>Site url:</td><td><input name=site_url value=\"$vars[site_url]\"></td></tr>";


echo "<tr><td>
<b>Picture 1:</b>
</td><td><input

type=file name=site_picture_1 value=\"$vars[site_picture_1]\"></td></tr>";


echo "<tr><td>
<b>Picture 2:</b></td><td><input type=file name=site_picture_2 value=\"$vars[site_picture_2]\"></td></tr>";

echo "<tr><td colspan=2>Description:<br><textarea cols=50 rows=3 name=site_description>$vars[site_description]</textarea></td></tr>";
echo "<tr><td colspan=2><input type=submit value=\"Submit site\"></td></tr>";
echo "</table>";
echo "</form>";
}






function add() {
global $db,$siteconfig;
$user = addslashes_data($_POST[user_name]);

if ($_GET[d_op] == "") {
include("templates/lt_header.php");
echo "<br><hr noshade>$siteconfig[site_join_text]<hr noshade>";
echo "Your site will show up on the list once you start sending visitors<p>";
addform('join','');
} else if ($_GET[d_op] == "save") {
if ($_POST[site_name] == '' OR
$_POST[site_url] == '' OR
$_POST[site_description] == '' OR
$_POST[user_name] == "" OR
$_POST[user_pass] == "" OR
$_POST[user_email] == "") {
include("templates/lt_header.php");
errmsg(array("You did not fill in a required field"));
addform('join',$_POST);
} else {
if ($db->sql_numrows($db->sql_query("SELECT site_id FROM "._SITES_TABLE." WHERE LOWER(user_name) = '".strtolower($user)."'")) > 0) {
include("templates/lt_header.php");
errmsg(array('<p>There is already a user with that username. Please choose another one.<p>'));
} else {
setcookie('user',base64_encode("$_POST[user_name]:".md5($_POST[user_pass]).":".time()),NULL,'/','',0);
include("templates/lt_header.php");



$target_a = "images-1/";
$target_b = "images-2/";
$target_1 = $target_a . basename( $_FILES['site_picture_1']['name']);
$target_2 = $target_b . basename( $_FILES['site_picture_2']['name']);


if(move_uploaded_file($_FILES['site_picture_1']['tmp_name'], $target_1))
{

echo "The files ". basename( $_FILES['site_picture_1']['name']). " has been uploaded.";

}

else {

echo "Sorry, there was a problem uploading your file.";

}

if(move_uploaded_file($_FILES['site_picture_2']['tmp_name'], $target_2
))
{

echo "The files ". basename( $_FILES['site_picture_2']['name']). " has been uploaded.";


}

else {

echo "Sorry, there was a problem uploading your file.";

}


if($db->sql_query("INSERT INTO "._SITES_TABLE." VALUES (NULL, '$user', '".addslashes_data(md5($_POST[user_pass]))."', "
."'".addslashes_data($_POST[user_email])."', "
."'".time()."', "
."'".addslashes_data($_POST[site_name])."', "
."'".addslashes_data($_POST[site_url])."', "
."'".addslashes_data($_FILES[site_picture_1][name])."', "
."'".addslashes_data($_FILES[site_picture_2][name])."', "
."'".addslashes_data($_POST[site_description])."', '0','0','0','0')")){
echo "<p>Thank you for your submission! We will review it and add it soon! Be sure to put the <a href=\"$_SERVER[PHP_SELF]?op=code\">partner code</a> into your site.<p>";
} else {
errmsg($db->sql_error());
}
}
}
}
include("templates/lt_footer.php");
}


2) function update() {
global $db, $userconfig;
include('templates/lt_header.php');
echo "<p align=center><b>Update site</b></p>";
if (is_user($_COOKIE[user])) {
if ($_GET[d_op] != 'save') {

$site = $db->sql_fetchrow($db->sql_query("SELECT * FROM "._SITES_TABLE." WHERE LOWER(user_name) = '".strtolower($userconfig[user_name])."' LIMIT 1"));
addform('update',$site);
} else {

$target_a = "images-1/";
$target_b = "images-2/";
$target_1 = $target_a . basename( $_FILES['site_picture_1']['name']);
$target_2 = $target_b . basename( $_FILES['site_picture_2']['name']);


if(move_uploaded_file($_FILES['site_picture_1']['tmp_name'], $target_1))
{

echo "The files ". basename( $_FILES['site_picture_1']['name']). " has been uploaded.";

}

else {

echo "Sorry, there was a problem uploading your file.";

}

if(move_uploaded_file($_FILES['site_picture_2']['tmp_name'], $target_2))
{

echo "The files ". basename( $_FILES['site_picture_2']['name']). " has been uploaded.";

}

else {

echo "Sorry, there was a problem uploading your file.";

}
$db->sql_query("UPDATE "._SITES_TABLE." SET site_name = '".addslashes_data($_POST[site_name])."',
site_url = '".addslashes_data($_POST[site_url])."',
site_picture_1 = '".addslashes_data($_FILES[site_picture_1][name])."',
site_picture_2 = '".addslashes_data($_FILES[site_picture_2][name])."',
site_description = '".addslashes_data($_POST[site_description])."', user_email = '".addslashes_data($_POST[user_email])."', site_isactive='0' WHERE LOWER(user_name) = '$userconfig[user_name]'") or errmsg($db->sql_error());
echo "<p>Your changes have been saved. Your site has been deactivated until we can approve the changes.<p>";
}
} else {
loginform(urlencode('op=update'));
}

include('templates/lt_footer.php');
}
 
Discussioni simili
Autore Titolo Forum Risposte Data
L [PHP] problema con upload e javascript (upload multiplo) Javascript 2
P Problema con lettura filesystem del client da server! Upload multiplo foto. PHP 5
F Problema con upload di immagini che superano 2MB PHP 14
A Problema con Upload immagini PHP 9
F Problema con upload di file PHP 1
A problema con upload immagini multiple PHP 0
G Problema con upload immagini e IE7 PHP 6
V Problema con Pure Asp Upload Classic ASP 4
F Problema Upload file con Internet Explorer PHP 29
S Problema Dominio su Tiscali e upload con ADSL ALICE Domini 1
C problema upload immagini grandi con 4images Programmazione 0
D problema con upload [Era: info] PHP 13
R Problema query con ricerca id numerico PHP 2
F Problema con risposta PHP 0
S problema con recupero dati tabella mysql PHP 2
Z Problema con il mio tp-l i nk Reti LAN e Wireless 0
L Problema RAM con Tomcat 8 Apache 0
napuleone problema con sort e asort PHP 4
Z Problema con INT MySQL PHP 1
Z Problema database MySQL con XAMPP PHP 0
M Problema con controllo form in real time jQuery 6
Z Problema di sincronizzazione PAYPAL con PHP PHP 1
G Problema con Get page PHP 4
P Problema con require once PHP 6
P Problema con i package Java 1
A Problema login con Safari PHP 14
F INDESIGN: problema esportazione esecutivo per la stampa con foto B/N Webdesign e Grafica 0
S problema con css bootstrap3 HTML e CSS 4
M .load() problema con caricamenti dinamici di js Javascript 0
G Problema ------- con Query PHP 1
G Problema con Query PHP 1
T problema con select dinamica con jquery Javascript 0
S Problema con spazi bianchi HTML e CSS 4
A PROBLEMA: insert mysqli con dati Tagsinput Presentati al Forum 0
Tommy03 Problema con z-index HTML e CSS 3
M Problema inserimento parole con apostrofo nel db PHP 5
C Problema con dati meteo xml XML 1
S Problema con infrarossi videocamera IP Cam e Videosorveglianza 1
V Problema con librerie allegro5 c++ C/C++ 1
M Problema con php per calcolo costo percentuale PHP 7
S Problema con mysqli_num_rows PHP 18
grgfede Problema javascript con aruba Javascript 1
M Problema con visibility e radio button Javascript 2
Marti1! Problema con casella mail cancellata Posta Elettronica 3
L [PHP] Problema con Telegram PHP 1
tomorc [HTML] Problema con scroll bar (risolto) HTML e CSS 0
S Strano problema con i title su Google SEO e Posizionamento 3
P [ASP.Net] Problema ERR_INCOMPLETE_CHUNKED_ENCODING 206 (Partial Content) con Font ASP.NET 4
P [HTML] Problema ERR_INCOMPLETE_CHUNKED_ENCODING 206 (Partial Content) con Font HTML e CSS 1
N [Apache] problema con estensione php Apache 0

Discussioni simili