begood Posted October 16, 2011 Share Posted October 16, 2011 Hey, I need some help here, I'm trying to create a module but when I go to index?mod=CriarEmpresa it don't appear... But when I remove a function (criarempresa) it appears... Can some one tell me where is the error: <?php //This file cannot be viewed, it must be included defined('IN_EZRPG') or exit; class Module_CriarEmpresa extends Base_Module { public function start() { $this->tpl->display('criarempresa.tpl'); if ($_GET['act'] == 'criarempresa') { $this->criarempresa(); } } private function criarempresa() { $error = 0; $errors = Array(); //Check username $result = $this->db->fetchRow('SELECT COUNT(`id`) AS `count` FROM `<ezrpg>empresas` WHERE `nome`=?', array($_POST['nome'])); if (empty($_POST['nome'])) { $errors[] = 'Não inseriste um nome para a empresa!'; $error = 1; } else if (!isNome($_POST['nome'])) { //If username is too short... $errors[] = 'O nome da empresa deve conter mais de 3 carateres!'; //Add to error message $error = 1; //Set error check } else if ($result->count > 0) { $errors[] = 'O nome da empresa que inseriste já está registado!'; $error = 1; //Set error check } //Check verification code if (empty($_POST['reg_verify'])) { $errors[] = 'Não inseriste o códiog de verificação!'; $error = 1; } else if ($_SESSION['verify_code'] != sha1(strtoupper($_POST['reg_verify']) . SECRET_KEY)) { $errors[] = 'O código de verificação inserido não está correto!'; $error = 1; } //verify_code must NOT be used again. session_unset(); session_destroy(); if ($error == 0) { unset($insert); $insert = Array(); //Add new user to database $insert['nome'] = $_POST['nome']; $insert['categoria'] = $_POST['categoria']; $insert['categoria'] = {$player->username} global $hooks; //Run register hook $insert = $hooks->run_hooks('register', $insert); $new_player = $this->db->insert('<ezrpg>empresas', $insert); //Use $new_player to find their new ID number. $hooks->run_hooks('register_after', $new_player); $msg = 'Empresa criada com sucesso!'; header('Location: index.php?msg=' . urlencode($msg)); exit; } else { $msg = 'Desculpa, existem erros no registo da empresa:<br />'; $msg .= '<ul>'; foreach($errors as $errmsg) { $msg .= '<li>' . $errmsg . '</li>'; } $msg .= '</ul>'; $url = 'index.php?mod=Register&msg=' . urlencode($msg) . '&nome=' . urlencode($_POST['username']) header('Location: ' . $url); exit; } } } ?> Thanks... :) Quote Link to comment Share on other sites More sharing options...
Neon Posted October 16, 2011 Share Posted October 16, 2011 I see you have headers() in both parts of that IF in criarempresa(), so it just hits that. Then gets directed out of it. Thats why it goes to it without that function. Make sure on your headers you retain the act=criarempresa Just join the other parameters like the msg & mod with the ampersand & Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.