Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70762

Create a session and retrieve data from the server

$
0
0

@SmeRT59 wrote:

With the help of the http.post I send the data to the server where they are processed.
The code on the server:

      case "loginUser":

        $loginUsername  = filter_var($_REQUEST['username'], FILTER_SANITIZE_STRING, FILTER_FLAG_ENCODE_LOW);
		$loginPassword  = filter_var($_REQUEST['password'], FILTER_SANITIZE_STRING, FILTER_FLAG_ENCODE_LOW);

		$DB_SERVER = "
		$DB_USER = ";
		$DB_PASS = "
		$DB_NAME = "

		$con = mysqli_connect("$DB_SERVER","$DB_USER", "$DB_PASS", "$DB_NAME") or die ("cannot connect server ");

		echo nl2br("\n Подключение к базе прошло успешно!");
		echo json_encode($loginUsername);

		$query =mysqli_query($con, "SELECT * FROM Users WHERE username = '".$loginUsername."'");
		$numrows=mysqli_num_rows($query);

		if($numrows!=0){

			while($row=mysqli_fetch_assoc($query)){

				$dbusername=$row['username'];
				$dbpassword=$row['password'];
				echo nl2br("\n Пользователь ". $dbusername ." найден! Сейчас производим сравнение паролей...");
			}

			if($loginUsername == $dbusername && $loginPassword == $dbpassword) {

				$_SESSION['session_username']=$loginUsername;
				echo nl2br("\n Вход успешно выполнен!");

			} else {
				echo nl2br("\n Ошибка: Пароль неверен!");
				$json = '{"Status": "False"}';
			}

   } else {
	   echo json_encode(array('Message:' => 'User not found...'));
   }
   break;

With the help of the ntp.post I send the data to the server where they are processed. How do I get back to the meaning after running the script in the PHP on the server? They say that this is done with the help of JSON, but I do not know him. tell me how to implement it.
Unfortunately, at the moment, I can not attach the code on the mobile application.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70762

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>