How to redirect page which is in (php) folder?

How to redirect page which is in (php) folder?

i want to redirect from (index.php) which is outside php folder to (userpanel.php) which is in php folder.




when i m login from (index.php) and click on login button, it show me following error.
how can i redirect to (userpanel.php) which is in (php) folder.
this is tested on localhost.

The requested URL /govn/userpanel.php was not found on this server.

I don’t even know why you’re using Javascript for this

/* Redirect browser */
/* Make sure that code below does not get executed when we redirect. */

This is just one posibility of the thousands available. Probably yours will work too if you use the full address, me thinks

I mean, if you’re login in, you’d be checking that the account exists and name and password are correct. This is a job for the PHP script, not for Javascript (exceptions made if you use Node.js but then, why would you use PHP?)

Snippet from userlogin.php

 if($row>0) {
	$_SESSION['user'] = $uname;
echo "Login Successfully";

Snippet from userlogin.js

    success: function(data) {
          if (data == "Login Successfully") {
            window.location.replace("userpanel.php"); // here //window.location.replace("php/userpanel.php");  is not working


this is a relative link, does it exist at all? does the /php folder is a publicly (by HTTP) available path/URL?

Using PHP Header function is really easy to get the redirect working. Just make sure Nothing is outputted before the header function or it will crash.
How to redirect with PHP