How can I get this log search to work in this web app?
-
I am creating a web app. The web app performs certain functions and stores results in a log file on the server. I want to add more functionality to this app. My idea was to create a search function that will search the log file for whatever text the user submits and display it on the screen without refreshing the browser. The code I have so far is below. I'm not getting any errors, but it doesn't work. Whenever I click on the search button the page just sits there as if I never clicked anything. Please help me solve this. Thank you! ----------HTML------------ Search Log: <form id="search"> <input type="text" id="search_box" /> <input type="button" id="search_button" value="Search" / > </form> ---------jQuery/Javascript---------- $("#search_button").click( function(){ var id = $("#search_box").val(); $("#main").load('ajax.php?logsearch&id=' + id); }); ----------PHP/ajax.php-------------- $id = $_REQUEST["id"]; //print new search box with search text still in box exec("grep " . $id . " /path/to/the/log/myLog.log", $results); //Print customized statements for 0, 1, or more results if($results.length == 0){ echo "<b>0 results returned. Please try again.</b> "; }else if($results.length == 1){ echo "<b>1 result returned.</b> "; }else{ echo "<b>" . $results.length . " results returned.</b> "; } //print results foreach($results as $line){ echo $line . " "; }
-
Answer:
i would start by echoing the variable $id right before it is passed to the grep command. it is very important that you validate this variable because the user can enter malicious code here. have you considered using single quotes in case the user enters a search term that has a space?
Question... at Yahoo! Answers Visit the source
Related Q & A:
- How Can I Get Started As A Freelance Web Developer?Best solution by code.tutsplus.com
- How can I get a web design job in Toronto?Best solution by Yahoo! Answers
- How can I get my insert addresses to work again?Best solution by Yahoo! Answers
- How can I get my web cam to work on MSN?Best solution by Yahoo! Answers
- How can i get my comcast remote to work with my new tv?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.