la cartella images esiste, e ha pure i permessi 777, ma la cartella temporanea non so. Ieri sera mi funzionava lo script, poi avro' modificato qualcosa. (forse la parte in basso dove invia la mail per autenticare l'account.
ti posto il codice copleto:
[code]
<?
$dbhost = "localhost";
$dbusername = "root";
$dbuserpass = "";
$dbname = "iscrizione";
$cartella = "/images/"; //cartella in cui salvare le foto, controllare i permessi di scrittura!
function ControlloEmail($email){
$result = eregi("^[_a-z0-9+-]+(.[_a-z0-9+-]+)*@[a-z0-9-]+(.[a-z0-9-]+)+$",$email);
return $result;
}
mysql_connect ($dbhost, $dbusername, $dbuserpass);
if (!mysql_select_db($dbname)) die(mysql_error());
// Define post fields into simple variables
$first_name = $_POST['first_name'];
$cognome = $_POST['cognome'];
$username = $_POST['username'];
$email = $_POST['email'];
$indirizzo = $_POST['indirizzo'];
$citta = $_POST['citta'];
$stato = $_POST['stato'];
$giorno = $_POST['giorno'];
$mese = $_POST['mese'];
$anno = $_POST['anno'];
$peso = $_POST['peso'];
$altezza = $_POST['altezza'];
$capelli = $_POST['capelli'];
$occhi = $_POST['occhi'];
$sesso = $_POST['sesso'];
/* Lets strip some slashes in case the user entered
any escaped characters. */
$first_name = stripslashes($first_name);
$cognome = stripslashes($cognome);
$username = stripslashes($username);
$email = stripslashes($email);
$indirizzo = stripslashes($indirizzo);
$citta = stripslashes($citta);
$stato = stripslashes($stato);
$giorno = stripslashes($giorno);
$mese = stripslashes($mese);
$anno = stripslashes($anno);
$peso = stripslashes($peso);
$altezza = stripslashes($altezza);
$capelli = stripslashes($capelli);
$occhi = stripslashes($occhi);
$sesso = stripslashes($sesso);
$file_new_name = '';
$file_new_path = '';
if(ControlloEmail($email))
echo 'Indirizzo email corretto... si procederà con la registrazione nel db';
else {
echo 'Indirizzo email non valido!';
exit(0);
}
if (isset($_FILES) && is_uploaded_file($_FILES['miofile']['tmp_name'])){//se c'è un file da caricare...lo faccio!
// http://forum.html.it/forum/showthre...threadid=694523
$file_temp= $_FILES['miofile']['tmp_name'];
$file_new_name= time().'_'.$_FILES['miofile']['name']; //aggiungo un numero all'inizio
$file_new_path = $cartella . $file_new_name;
if($_FILES["miofile"]["type"] == "image/gif" || $_FILES["miofile"]["type"] == "image/jpg" || $_FILES["miofile"]["type"] == "image/png") {
// ESEGUO L'UPLOAD CONTROLLANDO L'ESITO
if (move_uploaded_file($file_temp, $file_new_path))
echo "File caricato correttamente";
else
echo "Si sono verificati dei problemi durante l'Upload. Ti preghiamo di segnalarci il problema, <a href=http://www.pm25.it/contatti.php>clicca qui.</a>";
} else //nn ha una estensione valida
die("ATTENZIONE. Puoi caricare solamente file con la seguenti estenzioni: .jpg .png .gif");
}
/* Do some error checking on the form posted fields */
if((!$first_name) || (!$cognome) || (!$username) || (!$email) || (!$indirizzo) || (!$citta) || (!$stato) || (!$giorno) || (!$mese) || (!$anno) || (!$peso) || (!$altezza) || (!$capelli) || (!$occhi) || (!$sesso)){
echo 'I campi non sono corretti!
';
include 'iscrizione.php'; // Show the form again!
/* End the error checking and if everything is ok, we'll move on to
creating the user account */
exit(); // if the error checking has failed, we'll exit the script!
}
/* Let's do some checking and ensure that the user's email address or username
does not exist in the database */
$sql_email_check = mysql_query("SELECT email FROM utenti WHERE email='$email'");
$sql_username_check = mysql_query("SELECT username FROM utenti WHERE utenti='$username'");
$email_check = @mysql_num_rows($sql_email_check);
$username_check = @mysql_num_rows($sql_username_check);
if(($email_check > 0) || ($username_check > 0)){
echo "Errore nella compilazione:
";
if($email_check > 0){
echo "[b]Quest'email è stata già registrata da un'altro utente.!
";
unset($email);
}
if($username_check > 0){
echo "Username già in uso da un'altro utente!
";
unset($username);
}
include 'iscrizione.php'; // Show the form again!
exit(); // exit the script so that we do not create this account!
}
/* Everything has passed both error checks that we have done.
It's time to create the account! */
/* Random Password generator.
http://www.phpfreaks.com/quickcode/R...nerator/56.php
We'll generate a random password for the
user and encrypt it, email it and then enter it into the db.
*/
function makeRandomPassword() {
$salt = "abchefghjkmnpqrstuvwxyz0123456789";
srand((double)microtime()*1000000);
$i = 0;
while ($i <= 7) {
$num = rand() % 33;
$tmp = substr($salt, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}
$random_password = makeRandomPassword();
$db_password = md5($random_password);
$query = "SELECT username FROM utenti WHERE username = '" . $username ."' OR email = '" . $email . "'";
$rs = mysql_query($query);
if(mysql_num_rows($rs)>0) {
echo "esiste già uno unsername o l'indirizzo email inserito";
} else {
// Enter info into the Database.
$info2 = htmlspecialchars($info);
$sql = mysql_query("INSERT INTO utenti (first_name, cognome, username, password, email, indirizzo, citta, stato, giorno, mese, anno, peso, altezza, capelli, occhi, sesso, nomei, signup_date, decrypted_password)
VALUES('$first_name', '$cognome', '$username', '$db_password','$email', '$indirizzo', '$citta', '$stato', '$giorno', '$mese', '$anno', '$peso', '$altezza', '$capelli', '$occhi', '$sesso', '$file_new_name', now(), '$random_password')") or die (mysql_error());
}
if(!$sql){
echo 'Errore nel creare il tuo account. Contatta il webmaster.';
} else {
$userid = mysql_insert_id();
$activatepath = "activate.php?id=$userid&code=$db_password";
// Let's mail the user!
$subject = "Messaggio da: $sitename";
$message = "Caro $first_name $cognome,
Sei stato appena registrato su $sitepath !
Per attivare l'account, clicca qui: $sitepath$activatepath
Dopo l'attivazione, inserisci questi dati:
Username: $username
Password: $random_password
Conserva Username e Password per un login futuro.
Grazie!
Webmaster, $sitename
Questa è un email automatica, non rispondere a quest'email!";
mail($email, $subject, $message, "From: $sitename <$adminemail>\nX-Mailer: PHP/" . phpversion());
echo 'Le informazioni per il tuo account ti sono stati inviati nella tua casella email! Controlla la tua email!';
}
?>