简体   繁体   中英

Can't access PHP file from another folder

I am trying to access a PHP file that is located in another folder.

$path =  $_SERVER['DOCUMENT_ROOT'];
echo $path;

It's displaying: /Applications/MAMP/htdocs/mysqli

I am trying to redirect to welcome_employer.php in the folder "... mysqli/employers". How can I do this?

header('Location:'.$path.'/employers/welcome_employer.php');

Thanks

See: How to make a redirect in PHP?

In particular, the

header('Location:'.$path.'/employers/welcome_employer.php');

Request will be interpreted, ultimately, by the browser. So rather then $path you need the site's base URL there.

I think you need to use path like

http://localhost/test/test.php

you can't use $_SERVER['DOCUMENT_ROOT'];

use $_SERVER['host']; and then give your directory path

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM