Skip to content

Commit

Permalink
Merge pull request #3 from bhamidou/user
Browse files Browse the repository at this point in the history
User
  • Loading branch information
bhamidou authored Oct 11, 2023
2 parents ab4e6f4 + ccab36a commit 4382b88
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
24 changes: 23 additions & 1 deletion Controller/Conexion/ConexionPartida.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require __DIR__.'/Controller/Conexion.php';
class ConexionPartida{
public function getPartida(){
public function getPartidas(){
$con = new Conexion();
$con->conectar();

Expand All @@ -23,6 +23,28 @@ public function getPartida(){
echo json_encode($rtn);
}

public function getPartida($id){
$con = new Conexion();
$con->conectar();

$consulta = "SELECT * FROM PARTIDA WHERE id = ?";

$stmt = mysqli_prepare(Conexion::$conexion, $consulta);
mysqli_stmt_bind_param($stmt, "i", $id);
mysqli_stmt_execute($stmt);

$resultados = mysqli_stmt_get_result($stmt);
$con->desconectar();

$rtn= [];

while ($fila = mysqli_fetch_row($resultados)) {
$rtn[] = $fila[0].",". $fila[1].",".$fila[2].",".$fila[3];
}

echo json_encode($rtn);
}

public function updatePartida($posicion){
$con = new Conexion();
$con->conectar();
Expand Down
16 changes: 16 additions & 0 deletions Controller/Conexion/ConexionUsuario.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,22 @@ public function updatePassword($id, $newPw){

}

function createUser($email, $pass, $nombre){
$con = new Conexion();
$con->conectar();

$consulta = "INSERT INTO USUARIO (email, pass, nombre) VALUES (?, ?, ?)";

$stmt = mysqli_prepare(Conexion::$conexion, $consulta);

$hashPw = md5($pass);

mysqli_stmt_bind_param($stmt, "sss", $email, $hashPw, $nombre);

mysqli_stmt_execute($stmt);

$con->desconectar();
}



Expand Down
6 changes: 1 addition & 5 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,10 @@
$v = explode('/', $paths);

unset($v[0]);
print_r($decode);

$cod = 200;
$mesg = "todo bien";

$partida = new Usuario(1, $decode['email'], $decode['pass']);
$partida->changePassword("1234");


switch ($requestMethod) {
case 'GET': {
Expand All @@ -32,7 +28,7 @@

if ($checkPersona) {
if (!empty($v[1] && !empty($v[2]))) {
$partida = new Usuario($v[1], $v[2]);
$user = new Usuario(1,$decode['email'], $decode['pass']);

$partida->crearTablero($v[1], $v[2]);

Expand Down

0 comments on commit 4382b88

Please sign in to comment.