private_guy Posted August 19, 2007 Share Posted August 19, 2007 Hi there, My script has an install.php file which if it exists, I want it to redirect to the install.php file. I entered this code in index.php: //---------------------------- // Checking If Install File Exists! //---------------------------- if(is_dir('./install.php') and $_SERVER['HTTP_HOST'] != 'localhost') { header("Location: ./install.php"); die(); } //---------------------------- // Finished Checking //---------------------------- But it didn't work, it just views index.php naturally, even if install.php exists, what I'm I doing wrong? Many thanks for your help. Best Regards, Private_Guy Link to comment https://forums.phpfreaks.com/topic/65710-if-installphp-exists-redirect-to-installphp/ Share on other sites More sharing options...
phpknight Posted August 19, 2007 Share Posted August 19, 2007 Well, you cannot use is_dir like that. install.php is a file, not a directory. Link to comment https://forums.phpfreaks.com/topic/65710-if-installphp-exists-redirect-to-installphp/#findComment-328188 Share on other sites More sharing options...
private_guy Posted August 19, 2007 Author Share Posted August 19, 2007 Oh really? Didn't know that, can you help me then? Link to comment https://forums.phpfreaks.com/topic/65710-if-installphp-exists-redirect-to-installphp/#findComment-328194 Share on other sites More sharing options...
lightningstrike Posted August 19, 2007 Share Posted August 19, 2007 First of all why on earth would you use is_dir() on a file. Please read the manual at php.net for functions you do not understand. instead use file_exists(); Link to comment https://forums.phpfreaks.com/topic/65710-if-installphp-exists-redirect-to-installphp/#findComment-328195 Share on other sites More sharing options...
private_guy Posted August 19, 2007 Author Share Posted August 19, 2007 Okay thanks, but this is the basic code which i want: If the file install.php exists then redirect to install.php else null Many thanks for your guys help and support. Link to comment https://forums.phpfreaks.com/topic/65710-if-installphp-exists-redirect-to-installphp/#findComment-328209 Share on other sites More sharing options...
private_guy Posted August 19, 2007 Author Share Posted August 19, 2007 Problem Solved, many thanks. Link to comment https://forums.phpfreaks.com/topic/65710-if-installphp-exists-redirect-to-installphp/#findComment-328214 Share on other sites More sharing options...
plutomed Posted August 19, 2007 Share Posted August 19, 2007 Press solved Link to comment https://forums.phpfreaks.com/topic/65710-if-installphp-exists-redirect-to-installphp/#findComment-328216 Share on other sites More sharing options...
LiamProductions Posted August 19, 2007 Share Posted August 19, 2007 I don't if this is solved... but: if(file_exists('directory/install.php')) { header('directory/install.php'); } else { something like that should work, i'm not sure about the header script i've never used it Link to comment https://forums.phpfreaks.com/topic/65710-if-installphp-exists-redirect-to-installphp/#findComment-328228 Share on other sites More sharing options...
plutomed Posted August 19, 2007 Share Posted August 19, 2007 header('location:directory/install.php'); Link to comment https://forums.phpfreaks.com/topic/65710-if-installphp-exists-redirect-to-installphp/#findComment-328237 Share on other sites More sharing options...
LiamProductions Posted August 19, 2007 Share Posted August 19, 2007 header('location:directory/install.php'); Yeah, I looked it up about 5 minutes ago because i had ago at making this scipt Link to comment https://forums.phpfreaks.com/topic/65710-if-installphp-exists-redirect-to-installphp/#findComment-328241 Share on other sites More sharing options...
private_guy Posted August 19, 2007 Author Share Posted August 19, 2007 Well I just use this, wouldn't this work? //---------------------------- // Checking If Install File Exists! //---------------------------- if(file_exists('./install.php') and $_SERVER['HTTP_HOST'] != 'localhost') { header("Location: ./install.php"); die(); } //---------------------------- // Finished Checking //---------------------------- Link to comment https://forums.phpfreaks.com/topic/65710-if-installphp-exists-redirect-to-installphp/#findComment-328250 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.