How can I use the header to redirect? I used to have a login. php: verify that the user name and password are correct. Then, use & nbsp; echo & quot; & lt; script & gt; & quot; & nbsp; echo & quot; window in php. locationprofile. php & quot; & nbs
I used to have a login. php file. after verifying that the user name and password are correct, I used it in php.
Echo "script";
Echo "window. location = 'profile. php '";
Echo "script"; jump. as a result, my colleague browsed in safari on the ipad. clicking the login button did not respond. the username and password can be seen in the address bar. I can log on to the pc using safari.
I wonder if I used window. location to extract the authentication login to login2.php and want to use the header for redirection. if I log on to the pc or ipad, I will stay in login2.php and will not jump to me.
Login2.php file:
$ Rootdoc = $ _ SERVER ['document _ root'];
Require_once $ rootdoc. '/login/db. php ';
Define ("DEBUG", TRUE );
If (isset ($ _ REQUEST ['username']) & isset ($ _ REQUEST ['pw '])
{
$ Username = $ _ REQUEST ['username'];
$ Pw = $ _ REQUEST ['pw '];
If (DEBUG)
{
$ Database = new db ('localhost', 'root', '123456', 'Practice ');
}
Else
{
$ Database = new db ('','','','');
}
$ Result = $ database-> query ('', 'users'," username = '$ username' and password =' $ pw '");
If ($ result)
{
$ Count = mysql_num_rows ($ result );
If ($ count)
{
$ Row = mysql_fetch_array ($ result );
$ _ SESSION ['cuid'] = $ row ['id'];
// Echo $ _ SESSION ['cuid'];
// Echo "script";
// Echo "window. location = 'profile. php '";
// Echo "script";
Header ('Location: 192.168.1.55/login/profile. php ');
// Login is under htdoc
}
Else
{
Echo "script";
Echo "document. getElementById ('login _ result'). style. visibility = 'visible ';";
Echo "document. getElementById ('login _ result'). innerHTML = 'username or passworld error .';";
Echo "script";
}
}
Else
{
Echo "script";
Echo "document. getElementById ('login _ result'). style. visibility = 'visible ';";
Echo "document. getElementById ('login _ result'). innerHTML = 'service cannot connect, try later ';";
Echo "script";
}
}
Else
{
Exit;
}
------ Solution --------------------
Your js has nothing to do with php. change it to this way,
Add http ://
Header ('Location: http: // 192.168.1.55/login/profile. php ');