I want to send data from one PHP file to another PHP file in a subfolder where the first PHP file is present. I have a folder named folder1 which has contains a PHP file named file1.php and I want to call another file named file2.php in a subfolder of folder1 named folder2. I am using the header() function like this in file1.php:
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'folder1/folder2/file2.php';
header("location:http://$host$uri/$extra?sms=".$msg."&num=".$msg_num);
Data is not passing. Is there any solution using header()? I can't use cURL because of some restrictions.
echo "location:http://$host$uri/$extra?sms=".$msg."&num=".$msg_num;$msgand$msg_num. As @jprofitt said, basically debugging 101, print the result and see if it matches your expectations. The only possibility here is that those variables aren't set and the query string is loaded with empty variables. Or, but you didn't say so, you've already echo'd something and you get the warning that headers are already sent, and the redirect never takes place. How do you see that the "data does not get passed to file2"? Have you triedvar_dump($_SERVER);?