deconnexion from the front for save

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Locked
laubro
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Fri Apr 03, 2009 6:04 pm

deconnexion from the front for save

Post by laubro » Fri Apr 03, 2009 6:32 pm

Hy

I develop my first component for joomla 1.5 and I want the users (registred) can change informations in theire account... but, when i'm connect in the front page, and when I want to "save" information, that deconnect me .... when I cancel operation that's right
code

the form
<button type="button" onclick="submitbutton('save')">Sauvegarder </button>

end of the form

<input type="hidden" name="option" value="com_joomloc" />
<input type="hidden" name="id" value="<?php echo $this->rows->id; ?>" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="controller" value="users" />



the controller code :

function save()
{

$model = $this->getModel('users'); // is'nt joomla users, it's my file

if ($model->storeusers()) {
$msg = JText::_('Informations enregistrées!' );
} else {
$msg = JText::_( 'Erreur lors de l\'enregistrement' );
}

$link = 'index.php?option=com_joomloc&controller=users&view=users&task=edit&test=test';

$this->setRedirect($link, $msg);
}


Model code :


function storeusers()
{
$row =& $this->getTable();

$data = JRequest::get( 'post' );

if (!$row->bind($data)) {
$this->setError($this->_db->getErrorMsg());
return false;
}


if (!$row->check()) {
$this->setError($this->_db->getErrorMsg());
return false;
}


if (!$row->store()) {
$this->setError($this->_db->getErrorMsg());
return false;
}

return true;
}

becyn
Joomla! Explorer
Joomla! Explorer
Posts: 458
Joined: Mon Aug 11, 2008 1:16 am
Location: Newburgh Ny , USA
Contact:

Re: deconnexion from the front for save

Post by becyn » Sun Apr 05, 2009 2:50 am

Your model code seems a bit ambiguous.

I like using :

Code: Select all

JTable::addIncludePath(your path to tables constructors);
 JTable::getInstance('users', 'Table'); 
This way there is no doubt about what is being called.

If you just pull the the whole array in, you can't do proper filtering of the data.
You should break it down and test it before allowing it to be stored.
What if only one field was filled in? Is it a valid email? Does the phone number have the correct amount of integers?
etc...

The more you error trap it, the better the data will be!
Learn something new every day!

laubro
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Fri Apr 03, 2009 6:04 pm

Re: deconnexion from the front for save

Post by laubro » Sun Apr 05, 2009 10:30 am

OK i've anderstand, in first i've create a folder "tables" with the "table" file in the component folder on front end.... but the function go to the component folder in the administrator for find it... that's right, i've copy my table file in the table folder to my component in administrator and it's ok
thank's you
by


Locked

Return to “Joomla! 1.5 Coding”