Hello all,
I was talking to Raju Gautam via PM as he had helped with the first part of the following code in this thread.
Now all I had to do at the end of that thread was post the code in phpInputParser.php into the else statement of the code he helped me developed:
<?php
if( isset($_POST['btnsearch']) ){
$intro = trim($_POST['search']);
// check if they typed introduction or intro then redirect them to introduction.html page.
if( $intro === 'introduction' || $intro === 'intro' ){
header("Location: introduction.html");
exit();
}
else{
// write the code in here that you wanted to do in phpInputParser.php file.
}
}
?>
So I pasted the entire code in phpInputParser.php inside the else’s suite, but I got a 500 error saying: HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.
This error only happens when one does not type ‘intro’ or ‘introduction’ intro the input and then submit it.
If it was ‘intro’ or ‘introduction’ then it goes to introduction.html successfully.
Meaning Raju’s code works successfully and so does phpInputParser.php (alone, when ran or viewed ina browsers alone); but, when phpInputParser is put into as the code inside the else of Raju’s code, then I get the error only when that else is executed. The if statement and its code runs fine when the condition is met.
Would someone please be willing to help me with fixing it so that the original phpInputParser.php code inside the else works properly? I think I mentioned this above, but it (phpInputParser.php) does work properly alone (when in its own file and not in the else).
I was able, through systematically commenting parts of the code, to determine that what is causing the error is in line 31 to 57. When I remove those lines, the code inside the else runs without error, but does not do anything as lines 31 - 57 are parts of the script.
Here is Raju’s code (the if statement that redirects to introduction.html) including the else that now contains everything before and the part of the else code that is causing the error:
if( isset($_POST['btnsearch']) ){
$intro = trim($_POST['search']);
// check if they typed introduction or intro then redirect them to introduction.html page.
if( $intro === 'introduction' || $intro === 'intro' ){
header("Location: introduction.html");
exit();
}
else{
// write the code in here that you wanted to do in phpInputParser.php file.
/*echo $intro;*/
if(!session_id()){
@session_start();
}
ini_set('display_errors',false);
ini_set('error_reporting',E_ALL);
require_once("phpsearch_files/config.php");
if(_SEARCH_DEMO){
if(isset($_REQUEST['leave_demo'])){
unset($_SESSION['_search_demo_url']);
}
if(isset($_SESSION['_search_demo_url']) && $_SESSION['_search_demo_url']){
$GLOBALS['_SEARCH_HTML_WEBSITES'] = array(
$_SESSION['_search_demo_url']
);
}
}
/*************************************************************/
/****** 500 error problem with bad-condition lies here ******/
$website_search_dynamic = new website_search_dynamic();
if(isset($_REQUEST['search'])){
$search_term = trim($_REQUEST['search']);
if(strlen($search_term) <= 0){
$website_search_dynamic -> error($website_search_dynamic->label("Please enter a search query."),true);
}else if(strlen($search_term) < $GLOBALS['_SEARCH_MIN_CHARS']){
$website_search_dynamic -> error($website_search_dynamic->label("Sorry, you must enter at least %d characters in your search query",$GLOBALS['_SEARCH_MIN_CHARS']),true);
}
$website_search_dynamic -> search($search_term);
}
if(!isset($_REQUEST['updateindex'])){
echo $website_search_dynamic -> render();
}
/*************************************************************/
/*************************************************************/
/* about 900 more lines of code that don't cause the problem, so i didn't want to bother you with them*/
}
}
?>
Thank you all for any and all help! I would and do sincerely and really appreciate it
Please let me know if you have any Questions, Comments, Concerns, or Solutions
Thanks in Advance & Best Regards,
Team 1504