[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[jfw] Re: Error validating an inscription of a user



Hello!

You are slightly wrong with the mailing list - it's about Joomla Framework, but I will try to answer.

I think that the problem is in this line:
$test = InscripcionesHelper::validarInscripcionAnual();

It should be:
$this->test = InscripcionesHelper::validarInscripcionAnual();

Dmitry

On Wednesday, July 9, 2014 1:26:50 AM UTC+3, Elena Atero Ureña wrote:

Hi,

I have a problem validating a registration by e-mail, which will pass the user a link with your validation key. The particular problem is that the view with the confirmation message is not displayed, but internally it works correctly.


In a file 'helper' I have a function that checks if the validation is successful, the code is as follows:


public function validarInscripcionAnual(){

  // Initialise variables.

  $app = JFactory::getApplication();

  $model = $this->getModel('validara');

  

  // Get the data from the form POST

  $clave = JRequest::getVar('key', 'get');

  // Now update the loaded data to the database via a function in the model

  $valido = $model->validar($clave);


  // check if ok and display appropriate message.

  if ($valido){

     return true;

  }

  else{

     return false;

  }

}


In the model I have the function 'validar' is called in file 'helper', which makes the necessary operations with the database. The code is as follows:


public function validar($clave){

  // set the variables from the passed data

  $key = $clave;


  // set the data into a query to update the record

  $db = JFactory::getDBO();

  $query = $db->getQuery(true);

  $q = $db->getQuery(true);


  $query->select('*');

  $query->from('#__anual');

  $query->where("clave='".$key."' ");

  $db->setQuery((string)$query);

  $resultado = $db->loadResult();

  

  if ($db->loadResult() == 0){

     return false;

  }

  else{

     $query->update(' #__anual');

     $query = "UPDATE #__anual SET validacion=1 where clave='".$key."'";

     $db->setQuery((string)$query);

    

     if (!$db->query() || !$db->q() ) {

          JError::raiseError(500, $db->getErrorMsg());

          return false;

     } else {

          return true;

     }

  }

}


In the view I call the function of the file 'helper', The code is as follows:


public function display($tpl = null){

  // Get some data from the models

  $item = $this->get('Item');

  $this->item = $item;

  $test = InscripcionesHelper::validarInscripcionAnual();


  // Check for errors.

  if (count($errors = $this->get('Errors')){

     JError::raiseError(500, implode('<br />', $errors));

     return false;

  }

  

  // Display the view

  parent::display($tpl);

}


And in the view template I show a message depending on the result of the previous function. The code is as follows:


<?php

  // No direct access to this file

  defined('_JEXEC') or die('Restricted access');

  

  if ($test)

  {

     echo "<h2>Enhorabuena.</h2>";

     echo "<p>Su inscripcion ha sido validada con exito.</p>";

     echo "<h4>Le esperamos en la academia!</h4>";

  }

  else {

     echo "Algo a ido mal";

  }

?>

--
Framework source code: https://github.com/joomla/joomla-framework
Visit http://developer.joomla.org for more information about developing with Joomla!
---
You received this message because you are subscribed to the Google Groups "Joomla! Framework Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-framework+unsubscribe AT googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-framework.