-
Ottenere nome utente?
Ciao a tutti!
Il mio intento è quello di aggiornare un campo del Database da un valore inserito dall'utente in una form.
La mia domanda è come aggiornarlo solo di quell'utente, mi spiego meglio:
$data->query("UPDATE tabella set campo=valore where username=nomeutente");
Come ottengo il nome utente?
Ho provato a fare così:
Codice PHP:
$user =& JFactory::getUser();
$username = $user->username;
Ma non trova la classe jFactory, che modulo dovrei importare?
Non so se è utile ma la pagina in questione è visualizzata in un iframe.
-
Risolto:
Codice PHP:
<?php
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) );
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
//JDEBUG ? $_PROFILER->mark( 'afterLoad' ) : null;
/**
* CREATE THE APPLICATION
*
* NOTE :
*/
$mainframe =& JFactory::getApplication('site');
$user =& JFactory::getUser();
echo $user->username;
?>