How can I use the header to redirect? I used to have a login. php. after verifying that the user name and password are correct, I will use & nbsp; echo & quot; & lt; script & gt; & quot; & nbsp; in php; echo & q: How can I use the header to redirect?
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 ://
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.