0

I am trying to redirect if working.php is present in folder other wise echo no file.
this script only echo's no file.
thanks.

<?php
$filename = 'working.php';
if(file_exists('$filename'))
{
 header( 'Location: welcome.php' ) ;
}
else
{
echo "NO FILE";
}
?>
3
Contributors
3
Replies
5
Views
5 Years
Discussion Span
Last Post by Tko_1
2

Hey I just tried your script, it didn't work for me so I changed it and this works:

<?php
$filename = 'file.php';
if(file_exists($filename))
{
 header( 'Location: welcome.php' ) ;
}
else
{
echo "NO FILE";
}
?>
0

@phorce: Good spot. Single quoted strings do not do variable substitution. So it was actually looking for a file named $filename

0

yes !!
once again phorce has saved me.
thank you.
not sure how i missed that.
any ideas to have the script auto reshresh after ?

header( 'Location: welcome.php' ) ;
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.