Browse Source

ユーザ

main
Miteruzo 1 year ago
parent
commit
71a047573a
2 changed files with 23 additions and 2 deletions
  1. +7
    -2
      create_user.php
  2. +16
    -0
      modules/user.mod.php

+ 7
- 2
create_user.php View File

@@ -5,8 +5,13 @@ require_once './db_connection.php';
require_once './modules/user.mod.php';


$chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+-./:;<=>?@[\]^_`~';

$user = new User;

$user -> name = $_GET['name'];
$user -> pass = $_GET['pass'];
$user -> insert ();
$user -> pass = implode (
array_map (fn () => $chars[rand (0, strlen ($chars) - 1)], range (1, 8)));

echo [$user -> insert () -> id];


+ 16
- 0
modules/user.mod.php View File

@@ -31,5 +31,21 @@ User

return $self;
}

public function
insert ():
Self
{
$sql = "
INSERT INTO
users (name, pass)
VALUES ('{$this -> name}', '{$this -> pass}')";
$GLOBALS['__db_connection'] -> query ($sql)
or die ("db_insert error $sql");

$this -> id = $GLOBALS['__db_connection'] -> insert_id;

return $this;
}
}


Loading…
Cancel
Save