LOGIN: Retrieve the variable IdUser

Hi scriptcase,
I have build a login page, with new security module.

This is my table user:
IdUser
Username -> Login
Password -> Password
Group

Each registered user has his own calendar, where adds and removes events.

Table calendar:
IdEvent
title
Date_start
Date_end
IdUser

How do I retrieve the variable IdUser for my calendar application?
D.

Re: LOGIN: Retrieve the variable IdUser

Hello sir,

You can check this example in our website:

Please check this link : http://www.scriptcase.net/phpgenerator/samples/tutoriais/calendar/calendar03.php

Regards

Re: LOGIN: Retrieve the variable IdUser

Hi, friends.
About is item, i need use var iduser for field value default to insert or to update.
I have all tables 4 field for audit
datecreate=datesysteminsert
usercreate=user login this know use
dateupdate=datesystemupdate

other need and, iduser login use modif to sql automatic in runtime for view only register for user, i need create security the nivel register for user.

Re: LOGIN: Retrieve the variable IdUser

you can store the userid in a global from the login form.

Re: LOGIN: Retrieve the variable IdUser

Freezer, excuse me, i are new use scritpcase.

You can write how to about this option. thanks

  1. i need modify sql before load form
    select * from callswait where iduser=var session user login module

  2. in options the fields audit in seccion value por default

option default value insert field usercreate=var session login module

option default value update field userupdate=var session login module

Re: LOGIN: Retrieve the variable IdUser

Go to control_login application

onValidate event put this code:


$sql="SELECT UserId FROM table_name WHERE username = {field_username}";
sc_lookup(dataset,$sql);
$user_id={dataset}[0][0];
sc_set_global($user_id); //<- check this macro in documentation

now you got global variable [user_id]

Re: LOGIN: Retrieve the variable IdUser

you can then extend your SQL where clause in your other forms/grids with something like:
userid = [user_id]

Re: LOGIN: Retrieve the variable IdUser

Hi, I’m trying to use your recomendation but I fail, I put this in control_login onValidate Event:


$sql="SELECT nombre FROM usuarios WHERE email = {login}";
sc_lookup(dataset,$sql);
$user_id={dataset}[0][0];
sc_set_global($user_id);

then on a grid aplication y use this SQL Select Statement:


SELECT 
  id,
  fecha_in,
  folios,
  remitente,
  empresa,
  consecutivo,
  pdf,
  estado,
  fisico,
  fecha_out,
  director,
  coordinador,
  otro1,
  otro2,
  gte_tecnico
FROM 
  cartas
WHERE
  director = '[user_id]'

Finally, in APPLICATION Global Variable I define this values: in Scope I check SESSION and GET and in Type I select In

When I see my grid I get this message (because I activate the Debug Mode):

(mysql): select count(*) from cartas where director = ‘’
(mysql): SELECT fecha_in, remitente, empresa, consecutivo, estado, fecha_out, id from cartas where director = ‘’ LIMIT 0,17

as you can see, I didn’t get any value for generate the grid.

Sorry, I am new with ScriptCase and I don’t have experience, maybe I forgot something? o I write something wrong?

Thanks in advice for your help.

Re: LOGIN: Retrieve the variable IdUser

does $user_id contain a value after onvalidate?

If so, try:
[user_id] = $user_id;

(instead of sc_set_global…)

Re: LOGIN: Retrieve the variable IdUser

Thank you very much Freezer,

After 4 days I find my problem:

I change this:

$sql="SELECT nombre FROM usuarios WHERE email = {login}";

for this:

$sql="SELECT nombre FROM usuarios WHERE email = $var_login";

the original code in control login is:


$var_login = sc_sql_injection({login});
$var_password = sc_sql_injection(md5({password}));

sc_lookup(ds_user, "select email, password from usuarios where email = $var_login and password = $var_password ");

if ({ds_user} != false)
{
	$sm_global_login = {login};	
	sc_set_global($sm_global_login);	
    sc_lookup(ds_user_app, "select grupos_aplicaciones.aplicacion from grupos_aplicaciones inner join usuarios_grupo on grupos_aplicaciones.grupo = usuarios_grupo.grupo where usuarios_grupo.usuario = '{login}' ");
	if ({ds_user_app} != false)
	{
		for($i = 0; $i < count({ds_user_app}); $i++)
		{		  
			sc_apl_status({ds_user_app[$i][0]}, 'on');
		}
	}
	
	sc_redir('treemenu');	
}
else
{
	sc_error_message("Acceso denegado ! comun?quese con el administrador del sistema.");
}

Re: LOGIN: Retrieve the variable IdUser

Sorry for write again about the same theme but:

In my localhost all work perfect, now when I create the deployment and store in a shared web-server this thing is crazy.

Some time the variable is empty, I logged out of application and login again and work, then I log out again and log with different user and the variable keep the other user, next time the variable is empty. I use Internet Explorer, Firefox and Chrome and the problem is the same.

Any idea with the “phantom” global variable?

Re: LOGIN: Retrieve the variable IdUser

See the following:
http://www.scriptcase.net/forum_en_us/index.php?topic=4008.msg9319#msg9319

Regards,
Scott.