Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class User{
- private $login;
- private $email;
- private $password;
- function __construct(){
- }
- function __construct2($login, $email, $password){
- $this->login = $login;
- $this->email = $email;
- $this->password = $password;
- }
- public function getLogin()
- {
- return $this->login;
- }
- public function setLogin($login)
- {
- $this->login = $login;
- }
- public function getEmail()
- {
- return $this->email;
- }
- public function setEmail($email)
- {
- $this->email = $email;
- }
- public function getPassword()
- {
- return $this->password;
- }
- public function setPassword($password)
- {
- $this->password = $password;
- }
- }
- <?php
- require_once ("User.php");
- $login = "root";
- $pass = "root";
- $host = "mylocalhost";
- $dbname = "user";
- $db = new PDO('mysql:host=localhost; dbname=user', $login);
- $user = new User();
- if($_SERVER['REQUEST_METHOD']=='POST'){
- $user->setLogin($_POST['login']);
- $user->setEmail($_POST['email']);
- $user->setPassword($_POST['password']);
- print_r($user->getLogin());
- $sql = "INSERT INTO users(login, email, password)
- VALUES ('$user->getLogin()', '$user->getEmail()', '$user->getPassword()')";
- $db->query($sql);
- }
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- </head>
- <body>
- <form action="../php/addUser.php" method="post">
- <lable>input you login</lable>
- <input type="text" name="login" id="login" >
- <lable>input you email</lable>
- <input type="text" name="email" id="email" >
- <lable>input you password</lable>
- <input type="password" name="password" id="password" >
- <button type="submit" name="btn">регистрация</button>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement