Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Getting the requested Code
- $Code = $_GET['Code'];
- //Importing database
- require_once('dbConnect.php');
- //Creating sql query with where clause to get an specific employee
- $sql = "SELECT * FROM Usuario WHERE Code='$Code' ";
- //getting result
- $r = mysqli_query($con,$sql);
- //pushing result to an array
- $result = array();
- $row = mysqli_fetch_array($r);
- array_push($result,array(
- "Code"=>$row['Code'],
- "user"=>$row['user'],
- "Pass"=>$row['Pass'],
- "TipoUsuario"=>$row['TipoUsuario']
- ));
- //displaying in json format
- echo json_encode(array('result'=>$result));
- mysqli_close($con);
- ?>
- <?php
- try{
- $dsn = "mysql:host=fdb3.runhosting.com;dbname=698193_admin";
- $username = "698193_admin";
- $password = "1234admin";
- $pdo = new PDO($dsn, $username, $password);
- }
- catch(PDOException $e)
- {
- echo "No se pudo conectar a la base de datos".$e- >getMessage();
- }
- try{
- $resultado = $pdo->prepare("SELECT Code,user,Pass,TipoUsuario FROM Usuarios WHERE Code = :Code ");
- $resultado->execute('Code'=>$Code);
- $registro=$resultado->fetchAll(PDO::FETCH_ASSOC);
- $json=json_encode($registro);
- return $json;
- }
- catch(PDOException $e){
- echo "No existe un registro con dicho código";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement