Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- phpinfo();
- exit();
- */
- class Applicativo {
- const HOST = 'localhost';
- const USERNAME = '//';
- const PASSWORD = '//';
- const DATABASE = '//';
- public $dbo;
- public function __constructor(){
- try{
- $this->dbo = new mysqli(self::HOST, self::USERNAME, self::PASSWORD, self::DATABASE);
- } catch (\Exception $e) {
- echo $e->getMessage();
- exit();
- }
- }
- public function save($dati){
- $nome = $dati['nome'];
- $cognome = $dati['cognome'];
- $data = $dati['data'];
- $password_cript = md5($dati['password']);
- $cellulare = $dati['cellulare'];
- try{
- $query = "INSERT INTO utenti
- (nome, cognome, password, cellulare)
- VALUES
- ('".$nome."','".$cognome."','".$password_cript."','".$cellulare."');
- ";
- $result = $this->dbo->query($query);
- } catch (\Exception $e) {
- echo $e->getMessage();
- exit();
- }
- if(!$result){
- die('Errore query: '.$query);
- }else{
- echo 'Query eseguita con successo';
- }
- }
- }
- if(isset($_POST['invia'])){
- $registrazione = new Applicativo();
- $registrazione->save($_POST);
- }else{
- ?>
- <form method="POST" action="#">
- <input type="text" name="nome" placeholder="Nome">
- <input type="text" name="nome" placeholder="Cognome">
- <input type="password" name="password" placeholder="Password">
- <input type="date" name="data" placeholder="Nascita (aaaa-mm-gg)">
- <input type="submit" name="invia" value="invia">
- </form>
- <?php
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement