mattkingston Posted March 22, 2020 Share Posted March 22, 2020 Hi all. I am in need of some help with a simple page search function. In short what i need is a way the user can search for a specific page name from the home index page. My site (local for now) will be constructed as follows: localhost/mysite/index.html 0001.html 0002.html ... 0132.html etc... The subpages will be added/modified externaly and may run into the hundreds of pages. For this reason mySQL will be hard to implement and somewhat overkill especialy for this simple search function. So, is there a way i can type the page to look for "0132" into the field and be forwarded onto the searched page "0132.html" I realise i could just type mysite/0132.html but the page may or may not exist and searching would be tiny bit more elegant. Simple for you guys i expect but im at a loss as all search functions use mySQL in addition. Many thanks for your help in advance! Regards, Matt. Quote Link to comment https://forums.phpfreaks.com/topic/310341-php-page-name-searchforwarding/ Share on other sites More sharing options...
cyberRobot Posted March 22, 2020 Share Posted March 22, 2020 What type of website are you building? Is it a blog or some kind of resource library? In other words, would the contents of all these pages be better suited for a database? Perhaps there's a way to build a single page in PHP which pulls the necessary information from the database based on a passed ID. Quote Link to comment https://forums.phpfreaks.com/topic/310341-php-page-name-searchforwarding/#findComment-1575665 Share on other sites More sharing options...
ginerjm Posted March 22, 2020 Share Posted March 22, 2020 Read up on the is_file function. Should be just what you need. Quote Link to comment https://forums.phpfreaks.com/topic/310341-php-page-name-searchforwarding/#findComment-1575670 Share on other sites More sharing options...
mattkingston Posted March 22, 2020 Author Share Posted March 22, 2020 Thanks for the suggestion, ill look into that. Sadly a database is out of the question as the pages i wish to add will be created by an external script. Basically i need a means of tracking deliveries of interbranch transfers, my store is a hub and id like to post tracking data for items shipped out (this is the part thats handled by a script running outside the website environment). Pages will be updated with order tracker info and dumped into the web server folder so i need a way a user can search by 6 digit order number which will pertain to the html file containing the afformentioned info. Regards. Quote Link to comment https://forums.phpfreaks.com/topic/310341-php-page-name-searchforwarding/#findComment-1575680 Share on other sites More sharing options...
ginerjm Posted March 22, 2020 Share Posted March 22, 2020 (edited) So - these people have the power/permission to add these built pages to your site? Is that why you won't know if they exist or not. $pageno = (some source - perhaps the current url); if (is_file( $path . "/$pageno". "html")) { header("Location: $path . $pageno . '.html'); exit(); } This all depends on the source of the page number and what location the pages are all stored in. Basically this is what I would do once my script figures those things out. Of course you have to decide how to handle the non-existent file condition. Edited March 22, 2020 by ginerjm Quote Link to comment https://forums.phpfreaks.com/topic/310341-php-page-name-searchforwarding/#findComment-1575681 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.