Pagina 2 di 2 primaprima 1 2
Visualizzazione dei risultati da 11 a 12 su 12
  1. #11
    Utente di HTML.it
    Registrato dal
    Mar 2006
    Messaggi
    58
    il primo codice php dell'ultimo mio post me l'ha incollato solo una piccola parte. Questo è tutto:

    Codice PHP:
    <?php  require_once('errors.inc');   class UserManager {   //   // verifies that this user name doesn't have any invalid   // characters in it.  please see Chapter 17: "Data   // Validation with Regular Expressions" for a discussion   // of the ereg function.   //   public function isValidUserName($in_user_name)   {     if ($in_user_name == ''         or ereg('[^[:alnum:] _-]', $in_user_name) === TRUE)       return FALSE;     else       return TRUE;   }    //   // - get connection   // - make sure the user name does not already exist.   // - add record to users table.   //   public function createAccount   (     $in_uname,     $in_pw,     $in_fname,     $in_email,     $in_year,     $in_month,     $in_day   )   {     //     // 0. quick input validation     //     if ($in_pw == '' or $in_fname == ''         or !$this->isValidUserName($in_uname))     {       throw new InvalidArgumentException();     }      //     // 1. get a database connection with which to work.     //    throws on failure.     //     $conn = $this->getConnection();      try     {       //       // 2. make sure user name doesn't already exist.       //       $exists = FALSE;       $exists = $this->userNameExists($in_uname, $in_conn);       if ($exists === TRUE)         throw new UserAlreadyExistsException();        //       // 3a. make sure the parameters are safe for insertion       //      and encrypt the password for storage.       //       $uname = $this->super_escape_string($in_uname, $conn);       $fname = $this->super_escape_string($in_fname, $conn);       $email = $this->super_escape_string($in_email, $conn);       $pw = md5($in_pw);        //       // 3b. create query to insert new user.       //       $qstr = <<<EOQUERY INSERT INTO Users       (user_name,password,full_name,user_email,birthdate)      VALUES ('$uname', '$pw', '$fname', '$email',              '$in_year-$in_month-$in_day') EOQUERY;        //       // 3c. insert new user       //       $results = @$conn->query($qstr);       if ($results === FALSE)         throw new DatabaseErrorException($conn->error);        //       // we want to return the newly created user id.       //       $user_id = $conn->insert_id;     }     catch (Exception $e)     {       if (isset($conn))         $conn->close();       throw $e;     }      //     // clean up and exit     //     $conn->close();     return $user_id;   } //... il file poi va avanti...

  2. #12
    Utente di HTML.it
    Registrato dal
    Mar 2006
    Messaggi
    58
    ma che palle allora è il forum che ne taglia 1 parte...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.