Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once 'connection.php';
- class User {
- private $db;
- private $connection;
- function __construct() {
- $this -> db = new DB_Connection();
- $this -> connection = $this->db->getConnection();
- }
- public function does_user_exist($email,$haslo,$imie,$nazwisko)
- {
- $query = "SELECT from uzytkownicy WHERE email='$email' and haslo = '$haslo' ";
- $result = mysqli_query($this->connection, $query);
- if(mysqli_num_rows($result)>0){
- $json['success'] = ' Welcome '.$email;
- echo json_encode($json);
- mysqli_close($this -> connection);
- }else{
- $query = "INSERT INTO uzytkownicy (email,haslo,imie,nazwisko) VALUES ('$email','$imie','$nazwisko',MD5('$haslo'))";
- $inserted = mysqli_query($this -> connection, $query);
- if($inserted == 1 ){
- $json['success'] = 'Acount created';
- }else{
- $json['error'] = 'Wrong';
- }
- echo json_encode($json);
- mysqli_close($this->connection);
- }
- }
- }
- $user = new User();
- if(isset($_POST['email']) && isset($_POST['haslo']) && isset($_POST['nazwisko']) && isset($_POST['imie'])) {
- $email = $_POST['email'];
- $haslo = $_POST['haslo'];
- $nazwisko = $_POST['nazwisko'];
- $imie = $_POST['imie'];
- if(!empty($email) && !empty($haslo) && !empty($imie) && !empty($nazwisko)){
- $encrypted_password = md5($haslo);
- $user-> does_user_exist($email,$haslo,$imie,$nazwisko);
- }else{
- echo json_encode("you must type both inputs");
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement