Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6384859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:49:39+00:00 2026-05-25T02:49:39+00:00

Disclaimer: It’s been a while since I last wrote any code. The quality of

  • 0

Disclaimer: It’s been a while since I last wrote any code. The quality of my code is likely to be sub-par. You’ve been warned.

I have a basic form that’s meant to search flat files on our server. The “search engine” I created as two select lists: one for the file names and one for the customer site files come from.

For a reason I can’t figure out, whatever option I select from the second select list is never captured when I hit Submit.

However, whatever option I select from the first select list is always captured.

What am I missing? I am sure it’s starting right at me…. Any hints welcome. Thank you.

Here’s my code:

<HTML>
<head><title>SEARCH TOOL - PROTOTYPE</title></head>
<body><h1>SEARCH TOOL - PROTOTYPE</h1>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<fieldset>
<legend>Filename (one item)</legend><select name="DBFilename" id="DBFilename">
<?php $con = mysql_connect("localhost",  "user", "pass"); if (!$con) {  die('Could not connect: ' . mysql_error());}
mysql_select_db("dev", $con) or die(mysql_error());
$result = mysql_query("select distinct filename from search_test");
while ($row = mysql_fetch_array($result))
{ ?>    <option value="<?php echo $row['filename']; ?>"><?php echo $row['filename']; ?></option> <?php } mysql_close($con); ?>
</select></fieldset>
<fieldset>
<legend>Site (one item)</legend><select name="DBSite" id="DBSite">
<?php $con = mysql_connect("localhost",  "user", "pass"); if (!$con) {    die('Could not connect: ' . mysql_error());}
mysql_select_db("dev", $con) or die(mysql_error());
$result = mysql_query("select distinct site from search_test");
while ($row = mysql_fetch_array($result))
{ ?>        <option value="<?php echo $row['site']; ?>"><?php echo $row['site']; ?></option> <?php } mysql_close($con);
?>
</select></fieldset>
<input type="submit" name="submit" value="submit" >
<input type="button" value="Reset Form" onClick="this.form.reset();return false;" />
</form>
</body>
</HTML>
<?php

if (isset($_POST['submit'])) {

        if (!empty($_POST['DBFilename'])) {doFileSearch();}
                elseif (!empty($_POST['DBSite'])) {doSite();}
}

function doFileSearch() {
$mydir = $_SERVER['DOCUMENT_ROOT'] . "/filedepot";
$dir = opendir($mydir);
$DBFilename = $_POST['DBFilename'];

$con = mysql_connect("localhost", "user", "pass");
if (!$con) {die('Could not connect: ' . mysql_error());}
mysql_select_db("dev", $con) or die("Couldn't select the database.");

$getfilename = mysql_query("select filename from search_test where filename='" . $DBFilename . "'") or die(mysql_error());

echo "<table><tbody><tr><td>Results.</td></tr>";
while ($row = mysql_fetch_array($getfilename)) {
                $filename = $row['filename'];
                echo '<tr><td><a href="' . basename($mydir) . '/' . $filename . '"  target="_blank">' . $filename . '</a></td></tr>';
        }
                echo "</table></body>";
}

function doSite() {
$mydir = $_SERVER['DOCUMENT_ROOT'] . "/filedepot";
$dir = opendir($mydir);
$DBSite = $_POST['DBSite'];

$con = mysql_connect("localhost", "user", "pass");
if (!$con) {die('Could not connect: ' . mysql_error());}
mysql_select_db("dev", $con) or die("Couldn't select the database.");

$getfilename = mysql_query("select distinct filename from search_test where site='" . $DBSite . "'") or die(mysql_error());

echo "<table><tbody><tr><td>Results.</td></tr>";
while ($row = mysql_fetch_array($getfilename)) {
                $filename = $row['filename'];
                echo '<tr><td><a href="' . basename($mydir) . '/' . $filename . '"  target="_blank">' . $filename . '</a></td></tr>';
        }
                echo "</table></body>";

}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:49:40+00:00Added an answer on May 25, 2026 at 2:49 am

    Complete re-re-write here => http://pastebin.com/raw.php?i=qi5F7X2e

    There are several problems with my form.

    • a) Neither one of my SELECT lists are ever empty.
    • b) I never check for return the values from my functions.

    This one is working.

    Thanks to all for taking the time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

DISCLAIMER: The following code is not something I would ever use in a real
Disclaimer: I have no experience using YUI at all. I was wondering how the
Disclaimer: JS novice I have a JS widget that depends on JQuery. The widget's
Disclaimer: I am new to python and django but have Drupal programming experience. I'm
Disclaimer: Never used php in my life. New to Unix and Jenkins I have
( Disclaimer: This question is not specific to ASP.NET) I have a control which
Disclaimer: I am not a C programmer. I have recently seen a friend's project.
Disclaimer: I have little experience with linq. One of my tasks at my work
Disclaimer While this question looked like a potential duplicate , it was resolved by
Disclaimer I have searched for duplicates, but I can't seem to find them. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.