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" /> <link rel="stylesheet" href="../static/style.css" type="text/css" media="screen" />
</head> </head>
<body> <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> <table>
<thead> <thead>
<tr> <tr>
@ -39,41 +32,16 @@
<td><?php echo $row[2]; ?></td> <td><?php echo $row[2]; ?></td>
<td><?php echo $row[3]; ?></td> <td><?php echo $row[3]; ?></td>
<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>
<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> </td>
</tr> </tr>
<?php endforeach ?> <?php endforeach ?>
</table> </table>
<form method="post" action="user_management.php"> <div style="text-align: right;">
<div class="input-group"> <a href="html/user_create_form.html" class="create_btn" >Crear</a>
<label>Nombre</label>
<input type="text" name="nombre" value="">
</div> </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> </body>
</html> </html>

View File

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

View File

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