the-sexy-slug Posted January 27, 2011 Share Posted January 27, 2011 Hello This is what I am wanting to do can it be done in php without database or mysql? Basically what I would like to do is from a seach box on my site I would like to take the search term that the user inputs into that search box and then place that seach term on a php page that is automatically generated with the filename search-term.php and is added to a sidebar. The keyword would also be placed on the webpage with a tag %searchterm% so I can have text "you searched for %searchterm%" and it will echo the users search term that they put into the search box. Like I said I am new to php coding so this is a project that I would like to try. It will involve auto generating php files and auto adding links to pages and keyword grabbing. I would like to do this with out mysql or databases. Link to comment https://forums.phpfreaks.com/topic/225807-can-this-be-done-with-php-my-newbie-learning-project/ Share on other sites More sharing options...
Bradley99 Posted January 27, 2011 Share Posted January 27, 2011 action="search-term.php" Or am i being naive? Lol Link to comment https://forums.phpfreaks.com/topic/225807-can-this-be-done-with-php-my-newbie-learning-project/#findComment-1165780 Share on other sites More sharing options...
joel24 Posted January 27, 2011 Share Posted January 27, 2011 I would use the .htaccess (URL rewriting) to pull all search terms from the URL (if you're running an apache server), i.e. www.yourdomain.com/search/searchTermHere Here is a tutorial on .htaccess URL rewriting Then use php to generate the page on demand and echo the search term... What are you searching through? Pages in your site, or pages on external sites? Without using a database I think you will be putting a lot of strain on your server unnecessarily... Link to comment https://forums.phpfreaks.com/topic/225807-can-this-be-done-with-php-my-newbie-learning-project/#findComment-1165787 Share on other sites More sharing options...
the-sexy-slug Posted January 27, 2011 Author Share Posted January 27, 2011 It would be a standard search form box on my site not any externam sites. What ever they put in that search box would then be made into a php page/file and linked to a sidebar file and echo the search term also in the generated page. Its a little project as I have seen a few flat file blogs etc that do not have this feature and I just thought it would be an interesting project to learn php with. Link to comment https://forums.phpfreaks.com/topic/225807-can-this-be-done-with-php-my-newbie-learning-project/#findComment-1165792 Share on other sites More sharing options...
joel24 Posted January 27, 2011 Share Posted January 27, 2011 have a look at this form tutorial to learn about forms Then you'll have to (as Bradley99 said) set the form's action="search-term.php" and method="POST" Then on search-term.php you can have code such as //assuming the search text input is named 'searchTerm' //check if searchTerm is being posted if (isset($_POST['searchTerm'])) { echo $_POST['searchTerm']; //do whatever else you want if a search term is } You can change the method to GET instead of POST, and the form input will be sent across in the URL such as www.domain.com/search-term.php?searchTerm=bunny rabbit Link to comment https://forums.phpfreaks.com/topic/225807-can-this-be-done-with-php-my-newbie-learning-project/#findComment-1165827 Share on other sites More sharing options...
the-sexy-slug Posted January 27, 2011 Author Share Posted January 27, 2011 Thanks for your reply. I will check them out I will update this thread as and when I have worked out the search form I am off now to do some newbie stuff lol Thanks again for you help. Link to comment https://forums.phpfreaks.com/topic/225807-can-this-be-done-with-php-my-newbie-learning-project/#findComment-1165829 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.