Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- articles.html
- outputs.html
- receipt.html
- id_user int(11)
- password_user varchar(50)
- type (admin,receipt,output)
- <?php
- header('Access-Control-Allow-Origin: *');
- header('Access-Control-Allow-Methods: GET, POST');
- require_once('../apis/connection.php');
- /*OBTIENE USERS*/
- if($_SERVER['REQUEST_METHOD']=='GET')
- {
- if(isset($_GET['id_user']) && isset($_GET['password_user']))
- {
- $json = '';
- $banner = true;
- $id=$_GET["id_user"];
- $pass=$_GET["password_user"];
- $connection = new MySqlServerConnection();
- $query = 'SELECT id_user, password_user,type from users where id_user=?and password_user=? ';
- $result=$connection->executeQuery($query, array($id,$pass));
- $json .= '{"status":0, "total":, "users":[';
- //fecha
- foreach ($result as $row) {
- $row = (Object)$row;
- if(!$banner) { $json .= ','; } else { $banner = false; }
- $json .= '{
- "id_user": "'.$row->id_user.'",
- "password_user": "'.$row->password_user.'",
- "type": "'.$row->type.'"
- }';
- } //cierre foreach
- $json .= ']}';
- echo $json;
- } //CIERRA IF
- }
- ?>
- [
- {
- "id_user": "56012",
- "password_user": "6648ede70727581930e0e2a0580408f5",
- "type": "admin"
- }
- ]
- function login(id_user,password_user,type)
- {
- console.log('ENTRE A LOGIN');
- var user =document.getElementById("user").value;
- var pass =document.getElementById("pass").value;
- console.log(user);console.log(pass);
- var fd = new FormData();
- //if (type == 'admin') {
- var data = $.ajax({
- type: "POST",
- url: "apis/user.php",//A que archivo enviara los parametros
- data: fd,//Parametros que se enviaran
- success: function(x){
- console.log(x);
- header('location: article.html');
- //redirigir a index si no mandar alerta
- },
- processData: false,
- contentType: false,
- }); //fin ajax
- console.log(data);
- //}
- }
Add Comment
Please, Sign In to add comment