What I did ...

function RegistrationUser () { $date_registration = date("dmY"); $sql_ver = $this->db->prepare("select login, email from users where login = :login and email = :email"); $sql_ver->execute(array('login' => $this->newParamArray[5], 'email' => $this->newParamArray[2])); $sql_ver->setFetchMode(PDO::FETCH_ASSOC); $user_date = $sql_ver->fetch(); if ($user_date['login'] == $this->newParamArray[5]){ echo"Π’Π°ΠΊΠΎΠΉ login ΡƒΠΆΠ΅ Π΅ΡΡ‚ΡŒ Π² систСмС"; } else { if ($user_date['email'] == $this->newParamArray[2]) { echo"Π’Π°ΠΊΠΎΠΉ email ΡƒΠΆΠ΅ Π΅ΡΡ‚ΡŒ Π² систСмС"; } else { $sql_registration = $this->db->prepare("insert users (name, lastname, login, email, sex, birthday, pass, main_photo, status, lang, data_registr) value ( :name, :lastname, :login, :email, :sex, :birthday, :pass, :main_photo, :status, :lang, :data_registr )"); $sql_registration->execute(array( 'name' => $this->newParamArray[0], 'lastname' => $this->newParamArray[1], 'login' => $this->newParamArray[5], 'email' => $this->newParamArray[2], 'sex' => $this->newParamArray[3], 'birthday' => $this->newParamArray[4], 'pass' => md5($this->newParamArray[6]), 'main_photo' => '', 'status' => 0, 'lang' => substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2), 'data_registr' => $date_registration )); if(!$sql_registration) { echo "ΠŸΡ€ΠΎΠΈΠ·ΠΎΡˆΠ»Π° ошибка, смотри Ρ„Π°ΠΉΠ» ошибок."; file_put_contents('system/PDOErrors.txt', mysql_error().'<br />', FILE_APPEND); } else { $_SESSION['us_login'] = $this->newParamArray[5]; $_SESSION['us_pass'] = $this->newParamArray[6]; $_SESSION['us_lang'] = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); //header("Location: /index.php"); echo "session dates: login:".$_SESSION['us_login']." pass: ".$_SESSION['us_pass']."<br />array dates: login:".$this->newParamArray[5]." pass: ".$this->newParamArray[6]."<br />base dates: email:".$user_date['email']; } } } } 

Checks only the login to the mail does not reach stops seeing the array with the data from the database, I do not understand why if they declare before the cycle!

  • Is any error message displayed? How do you determine that the $ user_date array is not visible? - cheops
  • It does not give errors, it takes the login and mail correctly from the database, when I print the $ user_date array through print_r in the first cycle that checks the logs, it displays the login and mail from the database correctly when I also print but in the cycle below that writes nothing - privetsh

1 answer 1

Wrong query logic, existing login may have other mail, and existing mail may have another login. Or 2 different requests for sampling, or 1in optimized.

PS I advise in the request to return COUNT, and compare it with 0, and limit 1.

  • I also thought about count, but I want to show the user exactly what is already in the database, it's more convenient for many, so tell me what 1in optimized query can be? - privetsh
  • @privetsh then advise this: SELECT login , mail FROM `` WHERE login = '' OR mail = '' LIMIT 2 then check at least 2 entries. - Manitikyl
  • Brilliant and great thanks !!!!!! - privetsh