Commit 5e2e5065 authored by Vytor Calixto's avatar Vytor Calixto 👾

Updated UserController

parent beac5a0f
<?php
require('DbCOnnection.php');
if(empty($_POST['id'])){
salvarUsuario(formToArray());
}
else
{
require('DbConnection.php');
if (empty($_POST['id'])) {
salvarUsuario(formToArray());
} else {
atualizarUsuario(formToArray());
}
function salvarUsuario($user) {
$values = implode(',', $user);
echo "<pre>";
print_r($values);
echo "</pre>";
$sql = "INSERT INTO tbUser (nome,email,senha) values ({$values}) ";
$result = mysql_query($sql);
function salvarUsuario($user)
{
$values = implode(',',$user);
$sql = "INSERT INTO tbUser (nome,email,senha) values ({$values}) ";
$result = mysql_query($sql);
if(!$result)
{
echo 'ERRO ao se cadastrar';
exit;
}
if (!$result) {
echo 'ERRO ao se cadastrar';
exit;
}
}
function atulizarUsuario()
{
function atulizarUsuario($user) {
$values = implode(',', $user);
//$sql = "UPDATE SET WHERE"
}
function formToArray() {
$user = array();
function formToArray()
{
$user = array();
$user['nome'] = isset($_POST['nome']) ? $_POST['nome'] : "";
$user['email'] = isset($_POST['email']) ? $_POST['nome'] : "";
$user['senha'] = isset($_POST['senha']) ? $_POST['senha'] : "";
return $user;
}
function ehSenhaIgual()
{
return $_POST['senha'] == $_POST['confirmarSenha'];
}
$user['nome'] = isset($_POST['nome']) ? $_POST['nome'] : "";
$user['email'] = isset($_POST['email']) ? $_POST['nome'] : "";
$user['senha'] = isset($_POST['senha']) ? $_POST['senha'] : "";
return $user;
}
function ehSenhaIgual() {
return $_POST['senha'] == $_POST['confirmarSenha'];
}
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment