Skip to content

Instantly share code, notes, and snippets.

@samuelhei
Last active September 26, 2015 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samuelhei/4cbfd8ecd5af9068099e to your computer and use it in GitHub Desktop.
Save samuelhei/4cbfd8ecd5af9068099e to your computer and use it in GitHub Desktop.
<?php
class BD {
function BD(){
$hostname = 'localhost';
$username = $_ENV['C9_USER'];
$senha = '';
$banco = 'oficina';
$db = mysql_connect($hostname, $username,$senha);
$con = mysql_select_db($banco, $db);
$this->con = $con;
}
function query($sql) {
$query = mysql_query($sql);
if(mysql_errno() > 0) {
if(debug) {
die( mysql_error().' ('.$sql.')' );
}
}
return $query;
}
function multiple($sql) {
$return = array();
$query = $this->query($sql);
while($data = mysql_fetch_array($query)){
$return[] = $data;
}
return $return;
}
function single($sql) {
$query = $this->query($sql);
return mysql_fetch_array($query);
}
}
?>
<div class="row">
<div class="large-12 columns">
<?php
$bad = array('.', '/', '%',chr(92));
$id = str_replace($bad,'',$_GET['acao']);
if(empty($id)) {
$id = 'login';
}
include('go/aplick/'.$id.'.php')
?>
</div>
</div>
<div class="row">
<div class="small-12 medium-6 columns">
<form action="<?php echo urlSite; ?>/go/controle/login.php" method="POST">
<label for="login">Login:</label>
<input type="email" name="login" id="login"/>
<label for="senha">Senha</label>
<input type="password" name="senha" id="senha"/>
<input type="submit" class="button" value="Entrar"/>
</form>
</div>
</div>1
auto_prepend_file = "/home/ubuntu/workspace/go/config.php"
<?php
require_once('funcoesBanco.php');
class Usuario {
var $login;
var $nome;
var $senha;
function Usuario(){
$bd = new BD();
}
function login(){
$login = $this->getLogin();
$senha = $this->getSenha();
$sql = 'select * from usuario
where login = "'.$login.'"
and senha = "'.$senha.'"';
return $this->bd->single($sql);
}
function setLogin($login) {
$this->login = $login;
}
function setNome($nome) {
$this->nome =$nome;
}
function setSenha($senha){
$this->senha = $senha;
}
function getLogin(){
return $this->login;
}
function getNome(){
return $this->nome;
}
function getSenha(){
return $this->senha;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment