Move user creation from to a separate file

This commit is contained in:
coolneng 2020-06-17 01:02:47 +02:00
parent 29c6d7bb6d
commit 219f440b26
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
5 changed files with 87 additions and 51 deletions

View File

@ -0,0 +1,38 @@
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Gestión de usuarios</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../../static/style.css" type="text/css" media="screen" />
</head>
<body>
<form method="post" action="../user_management.php">
<div class="input-group">
<label>Nombre</label>
<input type="text" name="nombre" value="">
</div>
<div class="input-group">
<label>usuario</label>
<input type="text" name="usuario" value="">
</div>
<div class="input-group">
<label>contraseña</label>
<input type="password" name="contraseña" value="">
</div>
<div class="select-input">
<label>rol</label>
<select id="rol" name="rol">
<option value="1">administrativo</option>
<option value="2">médico</option>
</select>
</div>
<div class="input-group">
<label>correo</label>
<input type="text" name="correo" value="">
</div>
<div class="input-group">
<button class="btn" type="submit" name="submit" >Guardar</button>
</div>
</form>
</body>

View File

@ -9,13 +9,6 @@
<link rel="stylesheet" href="../static/style.css" type="text/css" media="screen" />
</head>
<body>
<!--[if lt IE 8]>
<p class="browserupgrade">
You are using an <strong>outdated</strong> browser. Please
<a href="http://browsehappy.com/">upgrade your browser</a> to improve
your experience.
</p>
<![endif]-->
<table>
<thead>
<tr>
@ -39,41 +32,16 @@
<td><?php echo $row[2]; ?></td>
<td><?php echo $row[3]; ?></td>
<td>
<a href="index.php?edit=" class="edit_btn" >Editar</a>
<a href="html/user_create_form.html?edit=" class="edit_btn">Editar</a>
</td>
<td>
<a href="server.php?del=" class="del_btn">Borrar</a>
<a href="html/user_create_form.html?delete=" class="del_btn">Borrar</a>
</td>
</tr>
<?php endforeach ?>
</table>
<form method="post" action="user_management.php">
<div class="input-group">
<label>Nombre</label>
<input type="text" name="nombre" value="">
<div style="text-align: right;">
<a href="html/user_create_form.html" class="create_btn" >Crear</a>
</div>
<div class="input-group">
<label>usuario</label>
<input type="text" name="usuario" value="">
</div>
<div class="input-group">
<label>contraseña</label>
<input type="password" name="contraseña" value="">
</div>
<div class="select-input">
<label>rol</label>
<select id="rol" name="rol">
<option value="1">administrativo</option>
<option value="2">médico</option>
</select>
</div>
<div class="input-group">
<label>correo</label>
<input type="text" name="correo" value="">
</div>
<div class="input-group">
<button class="btn" type="submit" name="submit" >Guardar</button>
</div>
</form>
</body>
</html>

View File

@ -6,7 +6,18 @@ function userCreation(){
$pdo = connectDatabase("practica", "practica", "practica");
$message = createUser($pdo, $data);
closeDatabase($pdo);
$_SESSION['message'] = $message;
header('location: user.php');
}
function userModification(){
$id = $_GET["edit"];
$pdo = connectDatabase("practica", "practica", "practica");
header('location: user.php');
}
function userDeletion(){
$id = $_GET["delete"];
$pdo = connectDatabase("practica", "practica", "practica");
header('location: user.php');
}
@ -14,3 +25,12 @@ function userCreation(){
if (isset($_POST['submit'])) {
userCreation();
}
if (isset($_GET['edit'])) {
userModification();
}
if (isset($_GET['delete'])) {
userDeletion();
}

View File

@ -54,6 +54,16 @@ form {
border: none;
border-radius: 5px;
}
.create_btn {
text-decoration: none;
padding: 2px 5px;
background: #88B8E7;
color: white;
border-radius: 3px;
margin: 400px;
}
.edit_btn {
text-decoration: none;
padding: 2px 5px;