How to make contact form multilanguage - php

So I have to make contact form multilingual, but im stuck for 7 hours already.
SO i have to make ajax ok/error messages without duplicating code.
$language = $_GET["language"] OR $language == "en";
$language = $_GET["language"] OR $language == "es";
$language = $_GET["language"] OR $language == "pl";
if ($language == "en") {
$okMessage = 'Thank you, we will get back to you soon!';
$errorMessage = 'There was an error while submitting the form. Please try again later';
}
if ($language == "pl") {
$okMessage = 'Dziękujemy, skontaktujemy się niedługo';
$errorMessage = 'W wiadomości pojawił się błąd, prosimy spróbować później';
}
if ($language == "es") {
$okMessage = 'Gracias, nos pondremos en contacto con usted pronto!';
$errorMessage = 'Hubo un error al enviar la solicitud. Por favor intente de nuevo.';
}
So what i want my code to do is that when im on poland contact form page. like www.website.com/pl-contact-page.php?language=pl - it gives me error/success messages in poland

After reading this thread I decided to give my little help, I changed a bit your code to get it more easy and secure... what that you need is Query String and Parse String... the rest is simple... I tested on my localtest and works fine...
<?php
#ini_set('default_charset', 'UTF-8');
$gurl = $_SERVER['QUERY_STRING'];
$ourl = array();
parse_str($gurl, $ourl);
if (isset($ourl['language']) || (!empty($ourl['language']))) {
$language = htmlspecialchars($ourl['language'], ENT_NOQUOTES, 'UTF-8');
if ($language == "en") {
$okMessage = 'Thank you, we will get back to you soon!';
$errorMessage = 'There was an error while submitting the form. Please try again later';
} elseif ($language == "pl") {
$okMessage = 'Dziekujemy, skontaktujemy sie niedlugo';
$errorMessage = 'W wiadomosci pojawil sie blad, prosimy spróbowac pózniej';
} elseif ($language == "es") {
$okMessage = 'Gracias, nos pondremos en contacto con usted pronto!';
$errorMessage = 'Hubo un error al enviar la solicitud. Por favor intente de nuevo';
}
// echo $okMessage; #Debug purpose
// echo $errorMessage; #Debug purpose
} else {
echo ("No language available!");
}
?>
Version with my function get_messages() that detect the correct string code (UTF-8 or ANSI):
<?php
#ini_set('default_charset', 'UTF-8');
$gurl = $_SERVER['QUERY_STRING'];
$ourl = array();
parse_str($gurl, $ourl);
if (isset($ourl['language']) || (!empty($ourl['language']))) {
$language = htmlspecialchars($ourl['language'], ENT_NOQUOTES, 'UTF-8');
function get_messages($string) {
return mb_convert_encoding($string, 'UTF-8', mb_detect_encoding($string, 'UTF-8, ISO-8859-1', true));
}
if ($language == "en") {
$okMessage = get_messages('Thank you, we will get back to you soon!');
$errorMessage = get_messages('There was an error while submitting the form. Please try again later');
} elseif ($language == "pl") {
$okMessage = get_messages('Dziekujemy, skontaktujemy sie niedlugo');
$errorMessage = get_messages('W wiadomosci pojawil sie blad, prosimy spróbowac pózniej');
} elseif ($language == "es") {
$okMessage = get_messages('Gracias, nos pondremos en contacto con usted pronto!');
$errorMessage = get_messages('Hubo un error al enviar la solicitud. Por favor intente de nuevo');
}
// echo $okMessage; #Debug purpose
// echo $errorMessage; #Debug purpose
} else {
echo ("No language available!");
}
?>
http://localhost-test/contact-page.php?language=pl
http://localhost-test/contact-page.php?language=en
http://localhost-test/contact-page.php?language=es
http://localhost-test/contact-page.php
Notes: you have to echo somewhere your messages otherwise the code appears not working well...
I hope this helps.

Related

PHP Warning: ibase_query(): supplied resource is not a valid Firebird/InterBase link resource

When I submit the form of register new user or new client, this message error appears.
I'm using PHP 7.1.5 with IIS Server in a Windows 10 OS. The same code was working correctly and stop work from nothing.
Somebody can help me?
Here is the code:
enter code here
<?php
if (!isset($_SESSION)) {
session_start();
}
// Verifica se não há a variável da sessão que identifica o usuário
if (!isset($_SESSION['UsuarioID'])) {
// Destrói a sessão por segurança
session_destroy();
// Redireciona o visitante de volta pro login
header("Location: login.php"); exit;
}
if(isset($_POST['submit'])) {
$nome = $_POST['txt_nome'];
$email = $_POST['txt_email'];
$password = $_POST['txt_password'];
$cpassword = $_POST['txt_cpassword'];
$nivel = $_POST['txt_nivel'];
$pass=strcmp($password,$cpassword);
if($pass == 0){
$senha = md5($password);
}else{
echo 'As Senhas Não Conferem. Verifique!';
}
if ($nivel == '1 - Diretoria') {
$nivel = 1;
}else if ($nivel == '2 - Gerência'){
$nivel = 2;
}else if ($nivel == '3 - Usuários'){
$nivel = 3;
}
$cad_usur = "INSERT INTO C_USUR
(C_USUR_USUR,C_USUR_STUS,C_USUR_NOME,C_USUR_LGIN,C_USUR_PSWD,C_USUR_NIVL)
VALUES ((SELECT S_CONT_CONT FROM
SP_PROX_NRMO('0001','C_USUR')),'1','$nome','$email','$senha','$nivel')";
$insert_usur = ibase_query($cad_usur);
if($cad_usur == true){
echo 'Cadastro Realizado Com Sucesso';
}else{
echo 'Não foi possível cadastrar o usuário. Verifique!';
}
}
?>

Mobilpay return error http 404

i have an error in my mobilpay account and i it returns me that i can't pay with my card, any suggestions,help?
I use: prestashop 1.6.1.4
And mobilpay module installed.
This is the error:
IDS_Model_Purchase_INVALID_RESPONSE_STATUS , they told me that is problems with hosting account that returns me error 404
Here is a picture with the issue:
Validation Php file:
<?php
include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/mobilpay_cc.php');
require_once dirname(__FILE__).'/Mobilpay/Payment/Request/Abstract.php';
require_once dirname(__FILE__).'/Mobilpay/Payment/Request/Card.php';
require_once dirname(__FILE__).'/Mobilpay/Payment/Request/Notify.php';
require_once dirname(__FILE__).'/Mobilpay/Payment/Invoice.php';
require_once dirname(__FILE__).'/Mobilpay/Payment/Address.php';
$errorCode = 0;
$errorType = Mobilpay_Payment_Request_Abstract::CONFIRM_ERROR_TYPE_NONE;
$errorMessage = '';
if (strcasecmp($_SERVER['REQUEST_METHOD'], 'post') == 0)
{
if(isset($_POST['env_key']) && isset($_POST['data']))
{
#calea catre cheia privata
#cheia privata este generata de mobilpay, accesibil in Admin -> Conturi de comerciant -> Detalii -> Setari securitate
$privateKeyFilePath = dirname(__FILE__).'/Mobilpay/certificates/private.key';
try
{
$objPmReq = Mobilpay_Payment_Request_Abstract::factoryFromEncrypted($_POST['env_key'], $_POST['data'], $privateKeyFilePath);
switch($objPmReq->objPmNotify->action)
{
#orice action este insotit de un cod de eroare si de un mesaj de eroare. Acestea pot fi citite folosind $cod_eroare = $objPmReq->objPmNotify->errorCode; respectiv $mesaj_eroare = $objPmReq->objPmNotify->errorMessage;
#pentru a identifica ID-ul comenzii pentru care primim rezultatul platii folosim $id_comanda = $objPmReq->orderId;
case 'confirmed':
#cand action este confirmed avem certitudinea ca banii au plecat din contul posesorului de card si facem update al starii comenzii si livrarea produsului
$errorCode = $objPmReq->objPmNotify->errorCode;
$errorMessage = $objPmReq->objPmNotify->getCrc();
break;
case 'confirmed_pending':
#cand action este confirmed_pending inseamna ca tranzactia este in curs de verificare antifrauda. Nu facem livrare/expediere. In urma trecerii de aceasta verificare se va primi o noua notificare pentru o actiune de confirmare sau anulare.
$errorCode = $objPmReq->objPmNotify->errorCode;
$errorMessage = $objPmReq->objPmNotify->getCrc();
break;
case 'paid_pending':
#cand action este paid_pending inseamna ca tranzactia este in curs de verificare. Nu facem livrare/expediere. In urma trecerii de aceasta verificare se va primi o noua notificare pentru o actiune de confirmare sau anulare.
$errorCode = $objPmReq->objPmNotify->errorCode;
$errorMessage = $objPmReq->objPmNotify->getCrc();
break;
case 'paid':
#cand action este paid inseamna ca tranzactia este in curs de procesare. Nu facem livrare/expediere. In urma trecerii de aceasta procesare se va primi o noua notificare pentru o actiune de confirmare sau anulare.
$errorCode = $objPmReq->objPmNotify->errorCode;
$errorMessage = $objPmReq->objPmNotify->getCrc();
break;
case 'canceled':
#cand action este canceled inseamna ca tranzactia este anulata. Nu facem livrare/expediere.
$errorCode = $objPmReq->objPmNotify->errorCode;
$errorMessage = $objPmReq->objPmNotify->getCrc();
break;
case 'credit':
#cand action este credit inseamna ca banii sunt returnati posesorului de card. Daca s-a facut deja livrare, aceasta trebuie oprita sau facut un reverse.
$errorCode = $objPmReq->objPmNotify->errorCode;
$errorMessage = $objPmReq->objPmNotify->getCrc();
break;
default:
$errorType = Mobilpay_Payment_Request_Abstract::CONFIRM_ERROR_TYPE_PERMANENT;
$errorCode = Mobilpay_Payment_Request_Abstract::ERROR_CONFIRM_INVALID_ACTION;
$errorMessage = 'mobilpay_refference_action paramaters is invalid';
break;
}
}
catch(Exception $e)
{
$errorType = Mobilpay_Payment_Request_Abstract::CONFIRM_ERROR_TYPE_TEMPORARY;
$errorCode = $e->getCode();
$errorMessage = $e->getMessage();
}
}
else
{
$errorType = Mobilpay_Payment_Request_Abstract::CONFIRM_ERROR_TYPE_PERMANENT;
$errorCode = Mobilpay_Payment_Request_Abstract::ERROR_CONFIRM_INVALID_POST_PARAMETERS;
$errorMessage = 'mobilpay.ro posted invalid parameters';
}
}
else
{
$errorType = Mobilpay_Payment_Request_Abstract::CONFIRM_ERROR_TYPE_PERMANENT;
$errorCode = Mobilpay_Payment_Request_Abstract::ERROR_CONFIRM_INVALID_POST_METHOD;
$errorMessage = 'invalid request metod for payment confirmation';
}
$Mobilpay_cc = new Mobilpay_cc();
if(!empty($objPmReq->orderId) && $errorCode==0) {
$cart = new Cart(intval($objPmReq->orderId));
//real order id
$order_id = Order::getOrderByCartId($objPmReq->orderId);
if(intval($order_id)>0) {
$order = new Order(intval($order_id));
$history = new OrderHistory();
$history->id_order = $order_id;
$history->changeIdOrderState(intval(Configuration::get('MPCC_OS_'.strtoupper($objPmReq->objPmNotify->action))), intval($order_id));
$history->id_employee = 1;
$carrier = new Carrier(intval($order->id_carrier), intval($order->id_lang));
$templateVars = array('{followup}' => ($history->id_order_state == _PS_OS_SHIPPING_ AND $order->shipping_number) ? str_replace('#', $order->shipping_number, $carrier->url) : '');
$history->addWithemail(true, $templateVars);
}
else {
//create the order
$Mobilpay_cc->validateOrder($objPmReq->orderId, intval(Configuration::get('MPCC_OS_'.strtoupper($objPmReq->objPmNotify->action))), floatval($objPmReq->invoice->amount), $Mobilpay_cc->displayName);
}
}
header('Content-type: application/xml');
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
if($errorCode == 0)
{
echo "<crc>{$errorMessage}</crc>";
}
else
{
echo "<crc error_type=\"{$errorType}\" error_code=\"{$errorCode}\">{$errorMessage}</crc>";
}

PHP "Parse error: syntax error, unexpected '}'"

I have a problem with PHP and, although I spent a whole hour trying to find what's wrong, I can't find anything in the code.
I'm working with a MySQL database and an input form. The form should be used to add entries to a specific table in the database. However, it gives a "Parse error: syntax error, unexpected '}'" whenever I hit the "Submit" button.
I tried everything but nothing worked.
This is the code:
<?php
include 'config.php';
session_start();
if (!isset($_SESSION['login'])){
header("Location: index.html");
}
if(isset($_POST['submit']) && ($_POST['submit']=="Invia")){
if(isset($_POST['section'])){
$section = addslashes(filter_var($_POST['section'], FILTER_SANITIZE_STRING));
} else {
echo "Devi selezionare una sezione";
}
if(isset($_POST['offer'])){
$offer = addslashes(filter_var($_POST['offer'], FILTER_SANITIZE_STRING));
}
if(isset($_POST['title'])){
$title = addslashes(filter_var($_POST['title'], FILTER_SANITIZE_STRING));
} else {
echo "Devi impostare il nome del viaggio";
}
if(isset($_POST['datestart'])){
$datestart = date('Ymd', strtotime($_POST['datestart']));
} else {
echo "Devi selezionare una data di inizio";
}
if(isset($_POST['dateend'])){
$dateend = date('Ymd', strtotime($_POST['dateend']));
} else {
echo "Devi selezionare una data di fine";
}
if(isset($_POST['itinerary'])){
$itinerary = addslashes(filter_var($_POST['itinerary'], FILTER_SANITIZE_STRING));
} else {
echo "Devi inserire un itinerario";
}
if(isset($_POST['price'])){
$price = addslashes(filter_var($_POST['price'], FILTER_SANITIZE_STRING));
} else {
echo "Devi inserire un prezzo";
}
if(isset($_POST['includes'])){
$includes = addslashes(filter_var($_POST['includes'], FILTER_SANITIZE_STRING));
} else {
echo "Devi inserire La quota comprende!";
}
if(isset($_POST['pdfname'])){
$pdfname = addslashes(filter_var($_POST['pdfname'], FILTER_SANITIZE_STRING));
} else {
echo "Devi inserire un nome per il pdf";
  }
if(isset($_POST['section']) && isset($_POST['title']) && isset($_POST['datestart']) && isset($_POST['dateend']) && isset($_POST['itinerary']) && isset($_POST['price']) && isset($_POST['includes']) && isset($_POST['pdfname'])){
$data = new MysqlClass();
$data->connetti();
 
$query = "INSERT INTO " . $section . " (
`id` ,
`title` ,
`offer` ,
`datestart` ,
`dateend` ,
`itinerary` ,
`price` ,
`includes` ,
`pdfname`)
VALUES (
NULL,
'".$title."',
'".$offer."',
'".$datestart."',
'".$dateend."',
'".$itinerary."',
'".$price."',
'".$includes."',
'".$pdfname."');";
$data->query($query);
echo "Viaggio inserito con successo.";
$data->disconnetti();
}
} else {
header("Location: index.html");
}
?>
EDIT: I'm using Wamp as a local server. I'm starting to think that's the problem, although it seems unlikely.
EDIT 2: I tried switching to EasyPHP, but I still have the same problem: Parse error: syntax error, unexpected '}' in C:\Program Files (x86)\EasyPHP-DevServer-13.1VC11\data\localweb\input.php on line 50
if(isset($_POST['price'])){
else { //<<---- missing } before else
echo "Devi inserire un prezzo";
}
There is also an "extra" closing bracket at the end of the script
when you use if statement you should do like this
if(){
}else{
}
and as he told you above
if(isset($_POST['price'])){
else {
echo "Devi inserire un prezzo";
}
Thank You .

update php database with data of two

I have two tables where I need to display text in a table corresponding to the users of the users table.
So I did this:
$email = $_SESSION['email'];
$select = mysql_query("SELECT t.id, t.id_textos, t.userTitleSite, t.userTextSobre, t.userTextContatos, t.userTextMaisInfos FROM vms_textos t INNER JOIN vms_users u ON (t.id = u.id) LIMIT 1") or print (mysql_error());
while($res_select = mysql_fetch_array($select)){
$userTitleSite = $res_select["userTitleSite"];
$userTextSobre = $res_select["userTextSobre"];
$userTextContatos = $res_select["userTextContatos"];
$userTextMaisInfos = $res_select["userTextMaisInfos"];
$id = $res_select["id"];
and working.
Now i need to update this information straight from the INPUTS..
but I can not do because my field UPDATE must be wrong because it always resets everything after that grip on SUBMIT.
This is the code I'm using. Please see what is wrong:
$query=mysql_query("UPDATE vms_textos SET userTitleSite='$userTitleSite', userTextSobre='$userTextSobre', userTextContatos='$userTextContatos', userTextMaisInfos='$userTextMaisInfos' WHERE t.id=u.id");
Thanks!
[EDIT]
ALL IMPORTANT CODE:
// INCLUDES.PHP
// Starts
ob_start();
session_start();
// Globais
$startaction="";
// Ação
if(isset($_GET["acao"])){
$acao=$_GET["acao"];
$startaction=1;
}
// Conexão com o banco de dados
$conectar=new DB;
$conectar=$conectar->conectar();
// Metodos de Cadastro
if($startaction == 1){
if($acao == "cadastrar"){
$usuario=$_POST["usuario"];
$nome=$_POST["nome"];
$sobrenome=$_POST["sobrenome"];
$telefone=$_POST["telefone"];
$email=$_POST["email"];
$senha=$_POST["senha"];
if(empty($usuario) || empty($nome) || empty($sobrenome) || empty($telefone) || empty($email) || empty($senha)){
$msg="Preencha todos os campos!";
}
// Todos os campos preenchidos
else {
// Email válido
if(filter_var($email,FILTER_VALIDATE_EMAIL)){
// Senha inválida
if(strlen($senha) < 8){
$msg="As senhas devem conter no mínimo oito caracteres!";
}
// Senha válida
else {
// Executa a classe de cadastro
$conectar=new Cadastro;
echo "<div class=\"flash\">";
$conectar=$conectar->cadastrar($usuario, $nome, $sobrenome, $telefone, $email, $senha);
echo "</div>";
}
}
// Email invalido
else{
$msg="Digite seu e-mail corretamente!";
}
}
}
}
// Método de Login
if($startaction == 1){
if($acao == "logar"){
// Dados
$email=addslashes($_POST["email"]);
$senha=addslashes(sha1($_POST["senha"].""));
if(empty($email) || empty($senha)){
$msg="Preencha todos os campos!";
} else{
if(!filter_var($email,FILTER_VALIDATE_EMAIL)){
$msg="Digite seu e-mail corretamente!";
} else {
// Executa a busca pelo usuário
$login=new Login;
echo "<div class=\"flash\">";
$login=$login->logar($email, $senha);
echo "</div>";
}
}
}
}
// Método de Checar usuário
if(isset($_SESSION["email"]) && isset($_SESSION["senha"])){
$logado=1;
$nivel=$_SESSION["nivel"];
}
// LOGIN.PHP -- CLASSE DE LOGIN
class Login {
public function logar($email, $senha){
$buscar=mysql_query("SELECT * FROM vms_users WHERE email='$email' AND senha='$senha' LIMIT 1");
if(mysql_num_rows($buscar) == 1){
$dados=mysql_fetch_array($buscar);
if($dados["status"] == 1){
$_SESSION["email"]=$dados["email"];
$_SESSION["senha"]=$dados["senha"];
$_SESSION["nivel"]=$dados["nivel"];
setcookie("logado",1);
$log=1;
} else{
$flash="Usuário bloqueado! Entre em contato conosco!";
}
}
if(isset($log)){
$flash="Você foi logado com sucesso!";
} else{
if(empty($flash)){
$flash="Ops, digite seu e-mail e sua senha corretamente!";
}
}
echo $flash;
}
}
// CADASTRO.PHP -- CLASSE DE CADASTRO
class Cadastro{
public function cadastrar($usuario, $nome, $sobrenome, $telefone, $email, $senha){
// Tratamento das variaveis
$usuario=ucwords(strtolower($usuario));
$nome=ucwords(strtolower($nome));
$sobrenome=ucwords(strtolower($sobrenome));
$telefone=ucwords(strtolower($telefone));
$email=ucwords(strtolower($email));
$senha=sha1($senha."");
// Inserção no banco de dados
$validaremail=mysql_query("SELECT * FROM vms_users WHERE email='$email' OR usuario='$usuario'");
$contar=mysql_num_rows($validaremail);
if($contar == 0){
$insert=mysql_query("INSERT INTO vms_users(usuario, nome, sobrenome, telefone, email, senha, nivel, status) VALUES('$usuario','$nome','$sobrenome','$telefone','$email','$senha','1','0')");
} else{
$flash="Desculpe, mas já existe um usuário cadastrado com este e-mail em nosso sistema!";
}
if(isset($insert)){
// Cadatro ok
$flash="Cadastro realizado com sucesso, aguarde nossa aprovação!";
} else{
if(empty($flash)){
$flash="Ops, houve um erro em nosso sistema!";
}
}
// Retorno para o usuário
echo $flash;
}
}
$query=mysql_query("UPDATE vms_textos SET t.userTitleSite='$userTitleSite' WHERE t.id='u.id'");
$query=mysql_query("UPDATE vms_textos SET userTitleSite='$userTitleSite' WHERE t.id=u.id");
what field do u want to update in db? SET that particular field in mysql_query(). i mentioned here.. try like this if u set all fields then all fields are updated..

Unable to edit ints

I'm building an admin panel in PHP. I'm new to PHP and I can't get my edit page to work as I need it to. I can edit the name, but 2 values which represent "Active User" and "Access Level" are set to 0 and I can't change it from 0 on my edit page, only from PhpmyAdmin..
<?php
// Inserir o registo na BD
include_once ('config1.php');
// Estabelecer a ligação à BD
$connection = new mysqli('localhost', 'root', '123456', 'admin1');
//Verificar se a ligação foi estabelecida com sucesso
if (mysqli_connect_errno() ) {
echo "</h2>Erro no acesso a BD</h2>" . mysqli_connect_error();
exit();
}
// Validar se os campos do formulário foram preenchidos pelo utilizador
// Verificar se "username" foi enviado
if (isset($_POST['iusername']) == FALSE) {
echo ("Erro de submissão");
exit();
} else {
$username = trim($_POST['iusername']);
}
if (isset($_POST['inome']) == FALSE) {
echo ("Erro de submissão");
exit();
} else {
$nome = trim($_POST['inome']);
}
if (isset($_POST['inivel']) == FALSE) {
echo ("Erro de submissão");
exit();
} else {
$apelido = trim($_POST['inivel']);
}
if (isset($_POST['iativo']) == FALSE) {
echo ("Erro de submissão");
exit();
} else {
$telefone = trim($_POST['iativo']);
}
if (isset($_POST['iemail']) == FALSE) {
echo ("Erro de submissão");
exit();
} else {
$email = trim($_POST['iemail']);
}
if (isset($_POST['ipass']) == FALSE) {
echo ("Erro de submissão");
exit();
} else {
$pass = trim($_POST['ipass']);
}
if (isset($_POST['irpass']) == FALSE) {
echo ("Erro de submissão");
exit();
} else {
$repass = trim($_POST['irpass']);
}
// Função de validação do email (chamada mais abaixo no código)
function isValidEmail($email){
return #eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*#[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z] {2,3})", $email);
// Validar se o nº de caracteres do "username" está entre 4 e 12
if (strlen($username) < 4 || strlen($username) > 12) {
$erro = true;
$msgerro .= "<p>erro: \"username\" deve conter entre 4 e 12 caracteres</p>";
}
// Validar se o nome tem entre 3 e 40 caracteres
if (strlen($nome) < 3 || strlen($nome) > 40) {
//echo (strlen($nome));
$erro = true;
$msgerro .= "<p>erro: \"nome\" deve conter entre 3 a 40 caracteres</p>";
}
// Validação das passwords
$mudapass = false;
if (strlen($password) == 0 && strlen($rpassword) == 0) {
$mudapass = false;
} else {
$mudapass = true;
}
// 2.2. Validar o tamanho da password
if (strlen($password) < 4 || strlen($password)> 16) {
$erro = true;
$msgerro .= "<p>erro: \"password\" deve conter entre 4 a 16 caracteres</p>";
}
}
// 3. Validar se as duas passwords correspondem
if ($password != $rpassword) {
$erro = true;
$msgerro .= "<p>\"passwords\" não correspondem</p>";
}
// validação de email
// Chama a nova função "isValidEmail"
if (isValidEmail($email) == false) {
$erro = true;
$msgerro .= "<p>email inválido</p>";
}
// Final das validações (avisa caso algum erro seja detectado)
if ($erro) {
echo "<p>Formulário submetido com erros</p>";
echo $msgerro;
echo "<br>";
// Desenha 2 botões "Corrigir" e "Listar"
echo "<a class='ains' href='javascript:history.go(-1)' title='Volta à página anterior'>Corrigir </a>";
echo "<br/>";
echo "<a class='ains' href='lista.php'>Listar</a>";
exit();
}
if($password != $rpassword){
echo "ERRO: PASSWORDS SAO DIFERENTES";
}
$sql= "UPDATE usuarios SET
nome = '$nome';
email = '$email';
nivel = '$nivel';
ativo = '$ativo';
WHERE
usuario = '$username'";
if ($mudapass == TRUE) {
$sql = "UPDATE usuarios SET nome = '$nome',
password = '$password',
email = '$email',
nivel = '$nivel',
ativo = '$ativo', WHERE usuario = '$username'";
}
if ($mudapass == FALSE) {
$sql = "UPDATE usuarios SET
nome = '$nome',
email = '$email',
nivel = '$nivel',
ativo = '$ativo'
WHERE
usuario = '$username'";
}
$connection->query($sql);
// Lista users depois de actualizar
header("location:lista.php");
?>
It looks like a naming problem. Two of your variables don't seem to follow the same convention as the rest of them, and unless I'm missing some extra processing before the query, then you should change these two lines:
$apelido = trim($_POST['inivel']);
// ...several lines later
$telefone = trim($_POST['iativo']);
to this:
$nivel = trim($_POST['inivel']);
// ...several lines later
$ativo = trim($_POST['iativo']);

Categories