Remove arguments on database connection function
This commit is contained in:
parent
e6b26d963b
commit
e77f29b393
|
@ -1,10 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function connectDatabase(string $user, string $pass, string $db) {
|
function connectDatabase() {
|
||||||
$unix_socket = '.mysql/mysql.sock';
|
$connection = 'unix_socket';
|
||||||
|
$host = '.mysql/mysql.sock';
|
||||||
$charset = 'utf8mb4';
|
$charset = 'utf8mb4';
|
||||||
$dsn = "mysql:unix_socket=$unix_socket;dbname=$db;charset=$charset";
|
$db = 'practica';
|
||||||
$pdo = new PDO($dsn, $user, $pass);
|
$dsn = "mysql:$connection=$host;dbname=$db;charset=$charset";
|
||||||
|
$pdo = new PDO($dsn, "practica", "practica");
|
||||||
return $pdo;
|
return $pdo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<?php
|
<?php
|
||||||
include '../database.php';
|
include '../database.php';
|
||||||
|
|
||||||
$pdo = connectDatabase("practica", "practica", "practica");
|
$pdo = connectDatabase();
|
||||||
$data = findUser($pdo, $_GET["edit"]);
|
$data = findUser($pdo, $_GET["edit"]);
|
||||||
?> <form method="post" action="../user_management.php">
|
?> <form method="post" action="../user_management.php">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<label>contraseña</label>
|
<label>contraseña</label>
|
||||||
<input type="password" name="contraseña" value="">
|
<input type="password" name="contraseña" value="<?php echo $data[3]; ?>">
|
||||||
</div>
|
</div>
|
||||||
<div class="select-input">
|
<div class="select-input">
|
||||||
<label>rol</label>
|
<label>rol</label>
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<?php
|
<?php
|
||||||
include 'database.php';
|
include 'database.php';
|
||||||
|
|
||||||
$pdo = connectDatabase("practica", "practica", "practica");
|
$pdo = connectDatabase();
|
||||||
$list = listUsers($pdo);
|
$list = listUsers($pdo);
|
||||||
foreach($list as $row) :
|
foreach($list as $row) :
|
||||||
if(!$row[5]):
|
if(!$row[5]):
|
||||||
|
|
|
@ -3,7 +3,7 @@ include'database.php';
|
||||||
|
|
||||||
function userCreation(){
|
function userCreation(){
|
||||||
$data = $_POST;
|
$data = $_POST;
|
||||||
$pdo = connectDatabase("practica", "practica", "practica");
|
$pdo = connectDatabase();
|
||||||
createUser($pdo, $data);
|
createUser($pdo, $data);
|
||||||
closeDatabase($pdo);
|
closeDatabase($pdo);
|
||||||
header('location: user.php');
|
header('location: user.php');
|
||||||
|
@ -12,7 +12,7 @@ function userCreation(){
|
||||||
function userModification(){
|
function userModification(){
|
||||||
$data = $_POST;
|
$data = $_POST;
|
||||||
$id = $_POST["id"];
|
$id = $_POST["id"];
|
||||||
$pdo = connectDatabase("practica", "practica", "practica");
|
$pdo = connectDatabase();
|
||||||
editUser($pdo, $data, $id);
|
editUser($pdo, $data, $id);
|
||||||
closeDatabase($pdo);
|
closeDatabase($pdo);
|
||||||
header('location: user.php');
|
header('location: user.php');
|
||||||
|
@ -20,7 +20,7 @@ function userModification(){
|
||||||
|
|
||||||
function userDeletion(){
|
function userDeletion(){
|
||||||
$id = $_GET["delete"];
|
$id = $_GET["delete"];
|
||||||
$pdo = connectDatabase("practica", "practica", "practica");
|
$pdo = connectDatabase();
|
||||||
deactivateUser($pdo, $data, $id);
|
deactivateUser($pdo, $data, $id);
|
||||||
closeDatabase($pdo);
|
closeDatabase($pdo);
|
||||||
header('location: user.php');
|
header('location: user.php');
|
||||||
|
|
Loading…
Reference in New Issue