Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $host='localhost';
- $db='-';
- $user='-';
- $pass='-';
- $charset='utf8mb4';
- $dsn = "mysql:host=$host;dbname=$db;charset=$charset";
- $opt = [
- PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
- PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
- PDO::ATTR_EMULATE_PREPARES => false,
- ];
- try
- {
- $pdo = new PDO($dsn,$user,$pass, $opt);
- }
- catch(PDOException $e)
- {
- echo $e->getMessage();
- }
- class user {
- public function register($prenume, $nume, $mail, $parola)
- {
- echo('Accessed user class');
- try
- {
- $stmt = $pdo->prepare("INSERT INTO utilizatori(prenume, nume, email, parola) VALUES(:prenume, :nume, :email, :parola)");
- $stmt->bindparam(":prenume", $prenume);
- $stmt->bindparam(":nume", $nume);
- $stmt->bindparam(":email", $email);
- $stmt->bindparam(":parola", $parola);
- $stmt->execute();
- return $stmt;
- }
- catch(PDOException $e)
- {
- echo $e->getMessage();
- }
- }
- }
- $user = new User();
- $user->register('prenume','nume','email','parola');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement