Simple CRUD Using PHP MySql Bootstrap 4
README.md
Simple CRUD Using PHP MySql Bootstrap 4
Simple User Registration Using Just PHP
Installation
Create the table in the Database:
create table usuario( id integer primary key AUTO_INCREMENT, nome varchar(200) not null, sobrenome varchar(300) not null, idade integer not null, sexo char(1) not null )
Copy after login
Copy after login
Copy after login
Configure the Conexao.php file within the 'app/conexao' folder:
Add the code below within the getConexão() function, if your database is Mysql it is already the default.
Remember to change the data (dbname, user, password) in the connection according to your bank.
-Connection to MySql
if (!isset(self::$instance)) { self::$instance = new PDO('mysql:host=localhost;dbname=github', 'root', '', array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8")); self::$instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); self::$instance->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_EMPTY_STRING); } return self::$instance;
Copy after login
Copy after login
-Connection to PostgreSql
$host = 'localhost;port=5432'; $dbname = 'github'; $user = 'root'; $pass = ''; try { if (!isset(self::$instance)) { self::$instance = new \PDO('pgsql:host='.$host.';dbname=' . $dbname . ';options=\'--client_encoding=UTF8\'', $user, $pass); self::$instance->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); self::$instance->setAttribute(\PDO::ATTR_ORACLE_NULLS, \PDO::NULL_EMPTY_STRING); } return self::$instance; } catch (Exception $ex) { echo $ex.'<br>'; }
Copy after login
Copy after login
Credits
Brayan Monteiro
email: brayanmonteirooo@gmail.com
index.php
include_once "./app/conexao/Conexao.php";
include_once "./app/dao/UsuarioDAO.php";
include_once "./app/model/Usuario.php";
//instantiates classes
$user = new User();
$usuariodao = new UsuarioDAO();
?>
CRUD Simple PHP
.menu,
thead {
background-color: #bbb !important;
}
padding: 10px;
}
}