Buongiorno, il mio problema è il seguente: ho un file "registrati.php" dove è contenuto il form per al registrazione che ha come action un file di nome "registrazione.php", che include un file "newuser.class.php" dove è contenuta una classe (che viene instanziata nello script registrazione.php)... Ora in newuser.class.php inserisco l'utente, dove ogni utente può sbarrare le checkbox che indicano che in quel argomento sono preparati, con tutti i dovuti controlli si arriva al momento in cui devo memorizzare nella tabella "argument_signed" del database gli argomenti sottomessi dall'utente registrato in questo modo: "$Arguments = $_POST['argument'];" io so che in questo modo mi si dovrebbe restituire un array ma non è così perchè quando faccio subito dopo "echo count($Arguments);" commentando avviamente l' "header("Location: index.php");" così da visualizzare la pagina con il valore del count mi restituisce 1, infatti non entra nel ciclo for.... Vi posto il codice:

Codice PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <title>
            "Registrati"
        </title>
        <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
        <meta name="generator" content="HAPedit 3.0">
        <style type="text/css">
            @import url("registrati.css");
            a#viewcss{color: #00f;font-weight: bold}
        </style>
    </head>
    <body>
        <div id="container">
            <div id="header">
                <h1>I answer</h1>
            </div>
            <div id="navigation">
                <ul>
                    [*][url="index.php"]Home[/url]
                [/list]
            </div>
            <div id="content">
            <form action="registrazione.php" method="POST">
                <fieldset>
                    <legend>Dati anagrafici</legend>
                        <label>Username: <input name="Username" type="text"></label>

                        <label>Nome: <input name="Nome" type="text"></label>

                        <label>Cognome: <input name="Cognome" type="text"></label>

                        <label>Sesso: M <input type="radio" name="Sesso" value="M"/>
                                      F <input type="radio" name="Sesso" value="F" checked="yes"/>

                        </label>
                        <label>Data di Nascita: <input name="Datadinascita" type="date"></label>

                        <label>Luogo di Nascita: <input name="Luogodinascita" type="text"></label>

                        <label>Luogo di Residenza: <input name="Luogodiresidenza" type="text"></label>

                        <label>Provincia di Residenza: <input name="Provinciadiresidenza" type="text"></label>

                        <label>Indirizzo: <input name="Indirizzo" type="text"></label>

                        <label>Numero civico: <input name="Numerocivico" type="text"></label>

                        <label>CAP: <input name="CAP" type="text"></label>

                        <label>Indirizzo email: <input name="Email" type="text"></label>

                        <label>Conferma email: <input name="Confermaemail" type="text"></label>

                        <label>Password: <input name="Password" type="text"></label>

                        <label>Conferma Password: <input name="Confermapassword" type="text"></label>    
                </fieldset>
                <fieldset>
                    <legend>Argomenti sottomessi</legend>
                        <input type="checkbox" name="argument[]" value="html"/> HTML 
                        <input type="checkbox" name="argument[]" value="css"/> CSS 
                        <input type="checkbox" name="argument[]" value="javascript"/> JavaScript 
                        <input type="checkbox" name="argument[]" value="java"/> Java 
                        <input type="checkbox" name="argument[]" value="sql"/> SQL                        
                        <input type="checkbox" name="argument[]" value="jquery"/> JQuery                         
                        <input type="checkbox" name="argument[]" value="perl"/> Perl 
                        <input type="checkbox" name="argument[]" value="ruby"/> Ruby                         
                        <input type="checkbox" name="argument[]" value="c++"/> C++                         
                        <input type="checkbox" name="argument[]" value="c"/> C 
                         
                        <input type="checkbox" name="argument[]" value="analisi1"/> Analisi Matematica 1                         
                        <input type="checkbox" name="argument[]" value="analisi2"/> Analisi Matematica 2                         
                        <input type="checkbox" name="argument[]" value="programmazione"/> Programmazione 
                </fieldset>
                <input name="submit" type="submit" value="Registrati">    
            </form>
            <?php
                
include 'error_definition.php';
            
?>
            </div>
            <div id="footer">© 2013-Sito di Michele Bellocchi</div>
        </div>
    </body>
</html>
Codice PHP:
<?php

    
include "newuser.class.php";
     
    
$newuser = new NewUser();
    
$newuser->AddUser();
     
    echo 
"inserimento avvenuto
Un email é stato inviato per confermare l'attivazione del tuo account"
;
 
?>
Codice PHP:
<?php
    
class NewUser{
        
            private 
$db;
            
            public function 
NewUser(){
                include 
"funzioni_mysql.php";
                
                
$this->db = new MysqlClass();
            }
            
            public function 
AddUser(){
                
$this->ErrorReport();
            }
            
            protected function 
IsEmptyUsername(){
                if(empty(
$_POST['Username'])){
                    return 
TRUE;
                }else{
                    return 
FALSE;
                }
            }
                
            protected function 
IsEmptyEmail(){
                if(empty(
$_POST['Email']) OR empty($_POST['Confermaemail'])){
                    return 
true;
                }else{
                    return 
false;
                }
            }
            
            protected function 
IsEmptyPassword(){ 
                if(empty(
$_POST['Password']) OR empty($_POST['Confermapassword'])){
                    return 
TRUE;
                }else{
                    return 
FALSE;
                }
            }
            
            protected function 
VerifyPassword(){
                if(
$_POST['Password'] == $_POST['Confermapassword']){
                    return 
TRUE;
                }else{
                    return 
FALSE;
                }
            }
            
            protected function 
UsernameExists(){
                
$this->db->connetti();
                
$sql "SELECT * FROM users WHERE Username=".$_POST['Username'];
                
                
$res $this->db->query($sql);
                if(
$res && $row mysql_fetch_array($res)){
                    
$this->db->disconnetti();
                    return 
TRUE;
                }else{
                    
$this->db->disconnetti();
                    return 
FALSE;
                }
            }
            
            protected function 
EmailExists(){
                
$this->db->connetti();
                
$sql "SELECT * FROM users WHERE Email=".$_POST['Email'];
                
                
$res $this->db->query($sql);
                if(
$row mysql_fetch_array($res)){
                    
$this->db->disconnetti();
                    return 
TRUE;
                }else{
                    
$this->db->disconnetti();
                    return 
FALSE;
                }
            }
            
            protected function 
VerifyEmail(){
                
$pattern "^([a-zA-Z0-9])+([a-zA-Z0-9]+[-_\.]?)*([a-zA-Z0-9])+(@)([a-zA-Z0-9])+([a-zA-Z0-9]+[-_\.]?)*([a-zA-Z0-9])+(\.[a-z]{2,4})$";
                
                if(
ereg($pattern,$_POST['Email'])){
                    return 
TRUE;
                }else{
                    return 
FALSE;
                }
            }
            
            public function 
ErrorResult($num){
                
header("Location: form.php?alert=" $num);
                die;
            }
            
            protected function 
ErrorReport(){
            
                if(
$this->IsEmptyUsername()){
                    
$this->ErrorResult(1);
                }
                
                if(
$this->IsEmptyEmail()){
                    
$this->ErrorResult(2);
                }
                
                if(
$this->IsEmptyPassword()){
                    
$this->ErrorResult(3);
                }
                
                if(!
$this->VerifyPassword()){
                    
$this->ErrorResult(4);
                }
             
                if(
$this->UsernameExists()){
                    
$this->ErrorResult(5);
                }
             
                if(
$this->EmailExists()){
                    
$this->ErrorResult(6);
                }
                
                if(!
$this->VerifyEmail()){
                    
$this->ErrorResult(7);
                }
             
                
$this->InsertNewUser();
            }
            
            protected function 
GetKey(){
                
$car "aAbBcCdDeEfFgGhHiIlLjJkKmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789";
                
$dim 40;
                
srand((double)microtime()*1000000);
                
$string '';
                    for(
$inc=0$inc<$dim$inc++){
                        
$rand rand(0strlen($car)-1);
                        
$scar substr($car,$rand,1);
                        
$string $string $scar;
                    }
                return 
$string
            }
            
            protected function 
SendUSerMail($key){
                
$content "Benvenuto $_POST[Username],\r\n";
                
$content .= "per confermare la tua iscrizione devi cliccare sul seguente link:\r\n\r\n";
                
$content .= "http://127.0.0.1/projects/Progetto%20Database/verify_user.php?key=" $key;
                
                
mail($_POST['Email'], "Iscrizione al sito..."$content"From: [email]sassofonix@gmail.com[/email]>");
                
                return;
            }
            
            protected function 
InsertNewUser(){
                
$password md5($_POST['Password']);
                
$key_control $this->GetKey();
                
                
#Memorizzo i valori da inserire per l'utente
                
$Username addslashes($_POST['Username']);
                
$Nome addslashes($_POST['Nome']);
                
$Cognome addslashes($_POST['Cognome']);
                
$Sesso addslashes($_POST['Sesso']);
                
$Datadinascita addslashes($_POST['Datadinascita']);
                
$Luogodinascita addslashes($_POST['Luogodinascita']);
                
$Luogodiresidenza addslashes($_POST['Luogodiresidenza']);
                
$Provinciadiresidenza addslashes($_POST['Provinciadiresidenza']);
                
$Indirizzo addslashes($_POST['Indirizzo']);
                
$Numerocivico addslashes($_POST['Numerocivico']);
                
$CAP addslashes($_POST['CAP']);
                
$Email addslashes($_POST['Email']);
                
$Password addslashes($password);
                
$Affidabilità addslashes(0);
                    
                
$t "`users`"# nome della tabella
                
$v = array ("NULL",$Username,$Nome,$Cognome,$Sesso,$Datadinascita,$Luogodinascita,$Luogodiresidenza,$Provinciadiresidenza,
                            
$Indirizzo,$Numerocivico,$CAP,$Email,$Password,$Affidabilità,$key_control); # valori da inserire
                
$r =  "`id`,`Username`,`Nome`,`Cognome`,`Sesso`,`Data di nascita`,`Luogo di nascita`,`Luogo di residenza`,`Provincia di residenza`,`Indirizzo`,`Numero civico`,
                    `CAP`,`Indirizzo email`,`Password`,`Affidabilità`,`key_control`"
# campi da popolare    
                
                
$this->db->connetti();
                
$this->db->inserisci($t,$v,$r);
                
                
//Inserisco gli argomenti
                
$Arguments $_POST['argument'];
                
                for(
$inc=1;$inc<count($Arguments);$inc++){
                    
$subcheck = (isset($Arguments[$inc])) ? 0;
                    if(
$subcheck==){
                        if(
$row mysql_fetch_array($res)){
                            
$id_user $row[id];
                            
$t "`argument signed`"# nome della tabella
                            
$v = array ($id_user,$inc); # valori da inserire
                            
$r =  "`id_user`,`id_arguments`";
                            
$db->inserisci($t,$v,$r);
                            echo 
'Argomento inserito';
                        }else{
                            echo 
'Non è stato possibile inserire l\'argomento';
                        }
                    }
                }
                
                
$this->db->disconnetti();
                
$this->SendUserMail($key_control);
                
header("Location: index.php");
            }
            
            public function 
VerifyUser(){
                
$sql "SELECT id FROM users WHERE key_control='$_GET[key]'";
                
$this->db->connetti();
                
$res $this->db->query($sql);
             
                if(
$row mysql_fetch_array($res)){
                    
$query "UPDATE users SET ver=1,key_control='0' WHERE id=".$row[id];
                    
$this->db->query($query);;
                    
$this->db->disconnetti();
                    echo 
"Il tuo account è ora attivato!";
                }else{
                    echo 
"Impossibile verificare l'account!";
                }
            }
        }
?>