File "CrearUsuario.php"
Full Path: C:/wamp64/www/casos_medicos1/model/CrearUsuario.php
File size: 770 bytes
MIME-type: text/x-php
Charset: utf-8
<?php
require_once 'conexion.php';
class UsuariosModel {
private $conn;
public function __construct() {
$this->conn = (new Conexion())->getConexion();
if (!$this->conn) {
throw new Exception("Error al conectar a la base de datos");
}
}
public function crearUsuario($nombre, $usuario, $clave, $perfil) {
$sql = "INSERT INTO usuarios (nombre, usuario, clave, perfil)
VALUES (?, ?, ?, ?)";
$stmt = $this->conn->prepare($sql);
if (!$stmt) {
throw new Exception("Error en prepare(): " . $this->conn->error);
}
$stmt->bind_param("ssss", $nombre, $usuario, $clave, $perfil);
return $stmt->execute();
}
}