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