This topic is locked

after application initialized error message: This page isn’t working localhost redirected you too many times

2/20/2019 10:55:13 PM
PHPRunner General questions
C
carrie3800332 author

Hi,

user can Register login Username and password

and manager other Unite Program login (not use phprunner Program login)

events after application initialized

to events function AfterAppInit()

if (($_SESSION['username']!='') or ($_SESSION['username']!=null))

{

header("Location: menu.php");

exit();

}
or
if(isset($_SESSION['username']))

{

header("Location: menu.php");

exit();

}
manager run Program have error message:

This page isn’t working localhost redirected you too many times.

Try clearing your cookies.

ERR_TOO_MANY_REDIRECTS
why?
Thanks!!

C
carrie3800332 author 2/21/2019

Hi,
1.user can Register login Username and password

and manager other Unite Program login (not use phprunner Program login)

events after application initialized

to events function AfterAppInit()
if (($_SESSION['username']!='') or ($_SESSION['username']!=null))

{

header("Location: menu.php");

exit();

}
or
if(isset($_SESSION['username']))

{

header("Location: menu.php");

exit();

}
manager run Program have error message:

This page isn't working localhost redirected you too many times.

Try clearing your cookies.

ERR_TOO_MANY_REDIRECTS
2.Because of the problem above,

will Program distinguish two part ,manager(security -no login / user(security -database)

manager run Program events function AfterAppInit() not work

Before being separated is work

why?
Thanks!!

[/quote]

admin 2/21/2019

Your code is incorrect and results in cyclical redirect. It does nothing but redirects user to the menu page over and over again.
What exactly you trying to achieve? What is something that built-in PHPRunner functionality cannot do?

C
carrie3800332 author 2/21/2019



Your code is incorrect and results in cyclical redirect. It does nothing but redirects user to the menu page over and over again.
What exactly you trying to achieve? What is something that built-in PHPRunner functionality cannot do?



phprunner 9.8(build29967)
this code Why incorrect and results in cyclical redirect.

How to write correctly

AfterAppInit()

header('Content-Type: text/html; charset=utf-8');

.

.

$_SESSION['username']=$D[0];

$_SESSION['fullname']=$D[4];
if(isset($_SESSION['username']))

{

header("Location: menu.php");

exit();

}
if (($_SESSION['username']!='') or ($_SESSION['username']!=null))

{

header("Location: menu.php");

exit();

}
because manager not login ,

Other programs pass the value of this program to receive the login data

error message:

This page isn’t working localhost redirected you too many times.

Try clearing your cookies.

ERR_TOO_MANY_REDIRECTS
this problem will Program distinguish two part ,

1.user Program login(security -database)

2.manager Program not login(security -no login )

but manager run Program events function AfterAppInit() not work

3.i test after use Program is login(security -database) or not login(security -no login ) AfterAppInit() not work

find /include/events.php content not AfterAppInit() Program Whether it is related to this?


Thank you for your reply.

admin 2/21/2019

Sorry, your explanation just doesn't make any sense at all.
Why your code is incorrect - this I can explain. AfterAppInit event is executed every time when you load any page of your application. If $_SESSION['username'] variable is set it will redirect user to the menu page. In the beginning of the menu page AfterAppInit event will be executed again, will redirect user to the same menu page etc.
You need to do something to only redirect user once.

C
carrie3800332 author 2/24/2019

I think of create temp_user table

when the table content is empty run this Program

{

header("Location: menu.php");

exit();

}

but manager user a lot of

I don't know if there will be other problems.

I am desperate for a quick solution so any help would be much appreciated

Or you have a better way

Many Thanks in advance

admin 2/24/2019

Yes, there are better ways. Your temporary table solution will only work if only one user can access your application at the time. Once you have more than one user results will be unpredictable.
You really need to explain what issue you trying to solve.

C
carrie3800332 author 2/25/2019



Yes, there are better ways. Your temporary table solution will only work if only one user can access your application at the time. Once you have more than one user results will be unpredictable.
You really need to explain what issue you trying to solve.


Generally used to register after login

manager a lot of logs in with other programs and passes the value(key)
AfterAppInit()

header('Content-Type: text/html; charset=utf-8');
direct to This (phprunner) program(not need to login)

Directly to


header("Location: menu.php");

exit();
i try add code AfterAppInit()
header('Content-Type: text/html; charset=utf-8');

...

$_SESSION['username']=$D[0];

$_SESSION['fullname']=$D[4];

$strSQLExistlusers="select from shortteacher_users where username ='".$_SESSION['username']."' and active='1' ";

$rsExistlusers = db_query($strSQLExistlusers);

$data=db_fetch_array($rsExistlusers);

if ($data["username"]='' or $data["username"]=null)

{

$strInsertlusers = "INSERT INTO shortteacher_users (UserName,fullname,active) values (";

$strInsertlusers .= "'".$_SESSION['username']."',";

$strInsertlusers .= "'".$_SESSION['fullname']."',";

$strInsertlusers .= "'".'1'."'";

$strInsertlusers .= ")";

db_exec($strInsertlusers,$conn);

}

db_exec($strSQLExistlusers,$conn);
$strSQLExistrs="select
from shortteacher_ugmembers where UserName ='".$_SESSION['username']."' ";

$rsExistrs = db_query($strSQLExistrs);

$data=db_fetch_array($rsExistrs);

if ($data["UserName"]='' or $data["UserName"]=null)

{

$strInsertrs = "INSERT INTO shortteacher_ugmembers (UserName,GroupID) values (";

$strInsertrs .= "'".$_SESSION['username']."',";

$strInsertrs .= "'".'1'."'";

$strInsertrs .= ")";

db_exec($strInsertrs,$conn);

}

db_exec($strSQLExistrs,$conn);

}
if (($_SESSION['username']!='') or ($_SESSION['username']!=null))

{

header("Location: menu.php");

exit();

}
but run program have error message:

This page isn't working localhost redirected you too many times.

Try clearing your cookies.

ERR_TOO_MANY_REDIRECTS
What should I do?

and there are better ways it?


Many Thanks in advance

admin 2/26/2019

You need to add the code that will only redirect user if they are not logged in. If they are logged in already - don't do anything.

if (user not logged in) {

- get those external variables

- log them in

- redirect

}


Log user in:

https://xlinesoft.com/phprunner/docs/secapi_loginas.htm
Check if user is logged in:

https://xlinesoft.com/phprunner/docs/secapi_isloggedin.htm

C
carrie3800332 author 3/3/2019



You need to add the code that will only redirect user if they are not logged in. If they are logged in already - don't do anything.

if (user not logged in) {

- get those external variables

- log them in

- redirect

}


Log user in:

https://xlinesoft.com/phprunner/docs/secapi_loginas.htm
Check if user is logged in:

https://xlinesoft.com/phprunner/docs/secapi_isloggedin.htm


1.if (user not logged in) {

Sorry, I don't know how to write this correct code?

My code has an error message:

and Already modified php.ini is memory_limit = 512M

Fatal error: Maximum execution time of 30 seconds exceeded in C:\AppServ\www\short_teacher\classes\xtempl_base.php on line 206

204 function assign_function( $name, $func, $params )

205 {

206 $this->xt_vars[$name] = XTempl::create_function_assignment( $func,$params );

207 }

my code is:

AfterAppInit()

.

Security::loginAs($username, $callEvent = true);

if (!empty($_SESSION['username']))

{

header ("Location:shortteacher_teacher_list.php");

exit();

}

or

session_start();

if (!(isset($_SESSION['username'])))

{

header ("Location:shortteacher_teacher_list.php");

exit();

}

or

if (!(isset($_SESSION['loggedin'])))

{

header ("Location:shortteacher_teacher_list.php");

exit();

}
2.- log them in

how to write this code?

Write there?login page?BeforeProcess or BeforeLogin...?
Thanks for any help !