Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready( function() {
- $('#logar').click(function(){
- var username = $("#username").val();
- var password = $("#password").val();
- $.ajax({
- url: 'controllers/Login.php',
- data: "username=" +username + "&password="+password ,
- type: 'GET',
- success: function(output) {
- alert(output);
- if(output != ''){
- window.location.href = "http://bravetech.com.br/politizar/representante.php";
- }
- else {
- alert('não logou');
- }
- }
- })
- });
- });
- $username = $_GET['username'];
- $password = $_GET['password'];
- //echo "<script>alert('$username');</script>";
- //admin@bravetech.com.br
- //admin
- session_name("start");
- session_start("start");
- $data = array(
- "username" => $username,
- "password" => $password
- );
- $data_string = json_encode($data);
- $ch = curl_init('http://politizar.azurewebsites.net/api/account/login');
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
- 'Content-Type: application/json',
- 'Content-Length: ' . strlen($data_string))
- );
- $result = curl_exec($ch);
- curl_close($ch);
- $dados = json_decode($result, true);
- //print_r($dados);
- $access = $dados['object']['access_token'];
- $sucess = $dados['isValid'];
- //echo $sucess;
- //echo "<script>alert('$sucess');</script>";
- if($sucess) {
- // echo "<script>alert('$sucess');</script>";
- $_SESSION['username'] = $username;
- $_SESSION['password'] = $password;
- }
- else {
- session_destroy();
- //echo "<script>alert('Nao foi');</script>";
- unset ($_SESSION['username']);
- unset ($_SESSION['password']);
- }
- echo $sucess;
- session_start("start");
- $representantes = listarRepresentante();
- echo $_SESSION['username'];
- session_start("start");
- if((!isset ($_SESSION['username']) == true) and (!isset ($_SESSION['password']) == true))
- {
- unset($_SESSION['username']);
- unset($_SESSION['password']);
- header('location:index.php');
- }
- $user = $_SESSION['username'];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement