Thanks Bob, I have read that thread and might be doing it right, I can't tell because every time I click "Submit" the form processes and the home page loads in its place. I figure this is due to a few possibilities which I will begin to explore, but maybe somebody can identify the problem faster than I will be able to poke around in the dark for a solution...
I figure:
1. I need to create a form to receive the search form data?
2. I need to specify 'something' for Redirect URL?
The challenge with the tutorial you reference for people new to CF is that it appears to be written for a previous version of CF and I believe I read somewhere that you indicated the hacks written to work with that tutorial were not to be used with the current version - thus none of the screen shots or directions are really applicable to the current version of CF which makes the discussion void.
I searched the internet and found an example of "how to make a simple search form" that looks like this (with the field names, table settings, etc. specific to the form / table I am working on):
// First check if a form was submitted.
// Since this is a search we will use $_GET
if (isset($_GET['search'])) {
$searchTerms = trim($_GET['search']);
$searchTerms = strip_tags($searchTerms); // remove any html/javascript.
if (strlen($searchTerms) < 3) {
$error[] = "Search terms must be longer than 3 characters.";
}else {
$searchTermDB = mysql_real_escape_string($searchTerms); // prevent sql injection.
}
// If there are no errors, lets get the search going.
if (count($error) < 1) {
$searchSQL = "SELECT id, lab_grade_by,lab_report_number,primary_inscription,secondary_inscription,diamond_shape,gem_type,date_registered FROM simple_search WHERE ";
// grab the search types.
$types = array();
$types[] = isset($_GET['lab'])?"`lab_grade_by` LIKE '%{$searchTermDB}%'":'';
$types[] = isset($_GET['title'])?"`lab_report_number` LIKE '%{$searchTermDB}%'":'';
$types[] = isset($_GET['inscription'])?"`primary_inscription` LIKE '%{$searchTermDB}%'":'';
$types[] = isset($_GET['inscription'])?"`secondary_inscription` LIKE '%{$searchTermDB}%'":'';
$types[] = isset($_GET['shape'])?"`diamond_shape` LIKE '%{$searchTermDB}%'":'';
$types[] = isset($_GET['gem_type'])?"`gem_type` LIKE '%{$searchTermDB}%'":'';
$types = array_filter($types, "removeEmpty"); // removes any item that was empty (not checked)
if (count($types) < 1)
$types[] = "`lab_grade_by` LIKE '%{$searchTermDB}%'"; // use the lab as a default search if none are checked
$andOr = isset($_GET['matchall'])?'AND':'OR';
$searchSQL .= implode(" {$andOr} ", $types) . " ORDER BY `lab_report_number'"; // order by title.
$searchResult = mysql_query($searchSQL) or die("There was an error.<br/>" . mysql_error() . "<br />SQL Was: {$searchSQL}");
if (mysql_num_rows($searchResult) < 1) {
$error[] = "The search term provided {$searchTerms} yielded no results.";
}else {
$results = array(); // the result array
$i = 1;
while ($row = mysql_fetch_assoc($searchResult)) {
$results[] = "{$i}: {$row['lab_grade_by']}<br />{$row['lab_report_number']}<br />{$row['primary_inscription']}<br />{$row['secondary_inscription']}<br />{$row['diamond_shape']}<br />{$row['gem_type']}<br />";
$i++;
}
}
}
}
function removeEmpty($var) {
return (!empty($var));
}
?>
<html>
<title>Search Registered Gems</title>
<style type="text/css">
#error {
color: red;
}
</style>
<body>
<?php echo (count($error) > 0)?"The following had errors:<br /><span id=\"error\">" . implode("<br />", $error) . "</span><br /><br />":""; ?>
<form method="GET" action="<?php echo $_SERVER['PHP_SELF'];?>" name="searchForm">
Search For: <input type="text" name="search" value="<?php echo isset($searchTerms)?$searchTerms:''; ?>" /><br />
Search In:<br />
Lab Graded by: <input type="checkbox" name="body" value="on" <?php echo isset($_GET['lab_grade_by'])?"checked":''; ?> /> |
Lab Report #: <input type="checkbox" name="title" value="on" <?php echo isset($_GET['lab_report_number'])?"checked":''; ?> /> |
Inscription #1: <input type="checkbox" name="desc" value="on" <?php echo isset($_GET['primary_inscription'])?"checked":''; ?> /><br />
Inscription #2: <input type="checkbox" name="desc" value="on" <?php echo isset($_GET['secondary_inscription'])?"checked":''; ?> /><br />
Gem Shape: <input type="checkbox" name="desc" value="on" <?php echo isset($_GET['diamond_shape'])?"checked":''; ?> /><br />
Match All Selected Fields? <input type="checkbox" name="matchall" value="on" <?php echo isset($_GET['matchall'])?"checked":''; ?><br /><br />
<input type="submit" name="submit" value="Search!" />
</form>
<?php echo (count($results) > 0)?"Your search term: {$searchTerms} returned:<br /><br />" . implode("", $results):""; ?>
</body>
</html>
But like I said, when Submit is clicked, the form processes and the home page loads. Now I'm wondering whether I should be breaking all of this down into sections of some sort and placing them in different parts of CC / CF for it to all work? If so, can somebody help me break them apart appropriately... I need "CF for Idiots"😲