Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Questa funzione aggiunge lo slash al carattere ' per rispettare la codifica del db
- function addbslash ($string)
- {
- return str_replace ("'", "\'", $string);
- }
- function chkmail ($e_mail)
- {
- //pulisco la stringa
- $e_mail = filter_var($e_mail, FILTER_SANITIZE_EMAIL);
- return (filter_var($e_mail, FILTER_VALIDATE_EMAIL));
- }
- //--------------------------------------------------------------------------------------------
- session_start();
- $name = addbslash($_POST['name']);
- $surname = addbslash($_POST['cognome']);
- $city = addbslash($_POST['città']);
- $prov = addbslash($_POST['provincia']);
- $adress = addbslash($_POST['indirizzo']);
- $phone = addbslash($_POST['telefono']);
- $email = addbslash($_POST['email']);
- $remail = addbslash($_POST['re-email']);
- $password = addbslash($_POST['password']);
- $repassword = addbslash($_POST['re-password']);
- //Se le mail sono diverse restituisco errore
- if (strcmp($email,$remail) != 0)
- {
- $_SESSION['errore'] = "mail";
- header("location:index.php?pag=big_error_frame");
- break;
- }
- //Se le password sono diverse restituisco errore
- if (strcmp($password,$repassword) != 0)
- {
- $_SESSION['errore'] = "password";
- header("location:index.php?pag=big_error_frame");
- break;
- }
- if ( chkmail ($email) != true && isset($_POST['registrati']))
- {
- $_SESSION['errore'] = "formato";
- header("location:index.php?pag=big_error_frame");
- break;
- }
- //Se è stato premuto il bottone annulla torno indietro
- if (isset($_POST['annulla']))
- {
- header("location: index.php");
- }
- //Se uno dei campi è nullo non permetto l'inserimento
- if ($name!=null && $surname!=null && $city!=null && $prov!=null && $adress!=null && $phone!=null && $email!=null && $password!=null && (isset($_POST['condizioni'])) && (isset($_POST['registrati'])))
- {
- $conn = pg_connect("host=127.0.0.1 dbname=Sito user=tia password=mattiaroot19872009");
- if (!$conn) echo ('Connessione fallita! <br />');
- $que = "select * from \"Utenti\" where email='$email'";
- $que = utf8_encode ($que);
- //DA CAMBIARE!:D
- $user = pg_query($que);
- $row = pg_fetch_assoc($user, 0);
- if (strcmp($row['email'], $email) == 0)
- {
- $_SESSION['errore'] = "utente";
- header("location:index.php?pag=big_error_frame");
- break;
- }
- $que = "insert into \"Utenti\"(id, nome, cognome, citta, provincia, indirizzo, email, pass, telefono, \"admin\") values (default,'$name', '$surname', '$city', '$prov', '$adress','$email','".md5($password)."', '$phone', false)";
- $que = utf8_encode ($que);
- $insert = pg_query($que);
- if (!$insert)
- {
- $_SESSION['errore'] = "query";
- header("location:index.php?pag=big_error_frame");
- }
- $_POST['registration'] = true;
- header("location:index.php?pag=big_reg_ok_frame");
- }
- else
- {
- if (isset($_POST['registrati']))
- {
- $_SESSION['errore'] = "campi";
- header("location:index.php?pag=big_error_frame");
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement