Jump to content
MakeWebGames

Helo with a module


begood

Recommended Posts

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... :)

Link to comment
Share on other sites

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 &

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...