Making Search Fields Compulsory

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   Making Search Fields Compulsory
jcb
CZ Active Member
 Codezwiz Site Donator
uk.gif
Occupation: Soldier
Age: 49
Gender: Male
Fav. Sports Team: England
Status: Offline
Joined: Oct 20, 2003
0.02 posts per day
Posts: 135
Points: 7,618
   
Hi all,

Anyone help me with a database coding issue.

I have a database that contains thousands of names. The search page contains 6 optional fields
On the search page I have two of the 6 fields that I wish to make compulsory. I.e you cannot commence the search without first filling in these two fields in the search option. Ive seen this sort of thing befor. When you click search a bow pops up saying:

"You must fill in the "***Field" and the "***Field" befor continueing"

Or words to that effect. I should think you know what I am on about now lol.

How do I go about doing this? Reason being is that if a user does not fill in any of the fields in the search options and then clicks search the whole database gets displayed, and if I have thousands of pieces of data in there it could be a problem for me.

The database programme is DaDaBIK. Dont know if you have used it.

Please can someone tell me how to achieve this?

Kind regards

Jon



Back to top Reply with quote
#2   
jcb
CZ Active Member
 Codezwiz Site Donator
uk.gif
Occupation: Soldier
Age: 49
Gender: Male
Fav. Sports Team: England
Status: Offline
Joined: Oct 20, 2003
0.02 posts per day
Posts: 135
Points: 7,618
   
I have trawled everysite I could think of and I am still at a loss icon_sad.gif

Is this a hard one?




_________________
PHP Super NooB
Back to top Reply with quote
#3   re: Making Search Fields Compulsory
Kelly_Hero
PayPal Donation
CZ Revered Member
 Codezwiz Site Donator
usa.gif southcarolina.gif
Occupation: Web Developer
Age: 59
Gender: Female
Website:
Status: Offline
Joined: Aug 20, 2003
0.48 posts per day
Posts: 3765
Points: 351,412
   
You will need to put in some form validation programming. It doesn't matter what type of database you're using. You don't mention what language you're using in your page, but if you Google for "form validation", you should find plenty of tutorials.



Back to top Reply with quote
#4   re: Making Search Fields Compulsory
jcb
CZ Active Member
 Codezwiz Site Donator
uk.gif
Occupation: Soldier
Age: 49
Gender: Male
Fav. Sports Team: England
Status: Offline
Joined: Oct 20, 2003
0.02 posts per day
Posts: 135
Points: 7,618
   
Hi K-H,

The language is English, I just did a search for form validation but I have no clue as to what I am looking for or where it is to be placed. I think it needs to go in the following file:

EDIT: I cant attatch php file.

The filed I want to make compulsory is called:

Last_Name

Thanks for youe help m8.




_________________
PHP Super NooB
Back to top Reply with quote
#5   
jcb
CZ Active Member
 Codezwiz Site Donator
uk.gif
Occupation: Soldier
Age: 49
Gender: Male
Fav. Sports Team: England
Status: Offline
Joined: Oct 20, 2003
0.02 posts per day
Posts: 135
Points: 7,618
   
OK,

I just spoke to the people at DaDaBIK and they say that doing this is impossible.

Is there anyone at CZ who can take on this task for me?

Surly it cant be impossible !! icon_eek.gif

Cheers to anyone who can help.




_________________
PHP Super NooB
Back to top Reply with quote
#6   re: Making Search Fields Compulsory
Kelly_Hero
PayPal Donation
CZ Revered Member
 Codezwiz Site Donator
usa.gif southcarolina.gif
Occupation: Web Developer
Age: 59
Gender: Female
Website:
Status: Offline
Joined: Aug 20, 2003
0.48 posts per day
Posts: 3765
Points: 351,412
   
OK, I did some reading on DaDaBIK. It's a PHP application which creates an interface which allows you to perform certain functions on a MYSQL database, such as searches, inserting and deleting records, etc.

I thought you were talking about a search form. I glanced briefly through the files that are included in the DaDaBIK download zip. I would imagine that since it's coded with PHP, it would be possible to modify the search form to do what you're wanting, but I have no clue as to how much the whole application would have to be modified. If the developers of DaDaBIK told you it can't be done, then either it can't be done, or it's too complicated, or they don't want you to...LOL

My question is, how are you using this application? Is it a way for visitors to your website to do a search? Or are you using it in a protected Administrators area on your site? Unless you're using it in a protected area where authorized people need to be able to perform functions on your database, you'd do just as well to have a regular search form on your site. You wouldn't want anyone who happens by to be able to insert or delete records from your database.



Back to top Reply with quote
#7   
jcb
CZ Active Member
 Codezwiz Site Donator
uk.gif
Occupation: Soldier
Age: 49
Gender: Male
Fav. Sports Team: England
Status: Offline
Joined: Oct 20, 2003
0.02 posts per day
Posts: 135
Points: 7,618
   
Ok,

The database I created for this programme sits outside my nuke database.
Basically it contains names. It is a genealogy site. I have disabled the ability for users to add/insert names into the database but I still need to protect from clicking search without entering any details into the search fields at it would bring up the entire database, and there are alot of names in there !!!

I want to protect the Last_Name field. So as you can see the search facility is the only one I can use as I dont know ho to create my own system. If you have any ideas then I am all ears.

Cheers K-H

NOJ75




_________________
PHP Super NooB
Back to top Reply with quote
#8   
jcb
CZ Active Member
 Codezwiz Site Donator
uk.gif
Occupation: Soldier
Age: 49
Gender: Male
Fav. Sports Team: England
Status: Offline
Joined: Oct 20, 2003
0.02 posts per day
Posts: 135
Points: 7,618
   
Ok I have had a think about this. Is DaDaBIK really what I want?

Basically i am after this:

I have a database containing the following fields:

(this database sits OUTSIDE of my nuke database)

Ser_No ---------- Unigue number and set as primary key.
Last_Name --------- Persons last name
First_Name --------- Persons first name
Parish ---------- Place where born
Born_In_County --------- Simple yes or no field
Age ------------ Obvious
Folio_Number ------------- Reference Number (not a unique number though)

I need a script that can:

1. search that database but having the Last_Name field required to be filled in.
2. Can display the results of the search.
3. Displays how many records the database contains in the search form.
4. If the results of a search brings up more than 1 record, then each record needs to have a link on it that can display the details of just that record.
5. Needs to be "visually nice"
6. A section to insert records to the database (but only for admins)

This is why i chose dadabik but to be honest I dont really need all the extras that come with it. Is there something else I can use or will dadabik still need to be edited?
I really would love to have my own system but I donnot have a clue on how to create this. Hope you or anyone out there can come up with some ideas for me.

Hope that explains things m8.

NOJ75




_________________
PHP Super NooB
Back to top Reply with quote
#9   re: Making Search Fields Compulsory
jcb
CZ Active Member
 Codezwiz Site Donator
uk.gif
Occupation: Soldier
Age: 49
Gender: Male
Fav. Sports Team: England
Status: Offline
Joined: Oct 20, 2003
0.02 posts per day
Posts: 135
Points: 7,618
   
Ok I am further on in my quest.

I have binned the dadabik system and gone for 2 simple pages which work fine.

Search.php and results.php

The following is the "meat" of search.php:

        OpenTable();
      
        echo "<table width=\"500\" align=\"center\" cellpadding=\"4\" cellspacing=\"0\" border=\"0\">"
            ."<tr><td><br><center>Testing Module</center><br></tr></td><br>"


             ."<form method=\"post\"  action=\"modules.php?name=My_Module_2&file=result\">"   
             ."<select name=\"metode\" size=\"1\">"
             ."<option value=\"Ser_No\">Serial Number</option>"
             ."<option value=\"Last_Name\">Last Name</option>"
             ."<option value=\"First_Name\">First Name</option>"
             ."<option value=\"Age\">Age</option>"
             ."<option value=\"Born_In_County\">Born In County</option>"
             ."<option value=\"Parish\">Parish</option>"
             ."<option value=\"Folio_Number\">Folio Number</option>"          
             ."</select> ;;"
             ."<input type=\"text\" name=\"search\" size=\"25\"> ;;"   
             ."<input type=\"submit\" value=\"Begin Searching!!\">"   
             ."</form></table>";

         CloseTable();


Now, how do I make the Last_Name field compusory to fill in?

Any ideas? Everything works fine except I need this field compulsory.

Thanks.



_________________
PHP Super NooB
Back to top Reply with quote
#10   re: Making Search Fields Compulsory
jcb
CZ Active Member
 Codezwiz Site Donator
uk.gif
Occupation: Soldier
Age: 49
Gender: Male
Fav. Sports Team: England
Status: Offline
Joined: Oct 20, 2003
0.02 posts per day
Posts: 135
Points: 7,618
   
Ok I have another problem.

For the results of the search.
If a search brings up more that one record from the databe it displays each of the records in a seperate table rather than just one. Here is the code I made:
//error message (not found message)
$XX = "Sorry, No Records Were Found";
$query = mysql_query("SELECT * FROM $usertable WHERE $metode LIKE '%$search%' LIMIT 0, 30 ");
while ($row  =  mysql_fetch_array($query))
   {
        $variable1=$row["Ser_No"];
        $variable2=$row["Last_Name"];
        $variable3=$row["First_Name"];
        $variable4=$row["Age"];
        $variable5=$row["Born_In_County"];
        $variable6=$row["Parish"];
      $variable7=$row["Folio_Number"];
   
      OpenTable();

echo"
<table width=\"100%\" border=\"1\" align=\"center\" bgcolor=\"#FFFFFF\">
           
  <tr>
    <td><p> ;;</p>
      <table width=\"100%\" border=\"1\">
            <tr>
            <td width=\"5%\">$variable1</td>
            <td width=\"20%\">$variable2</td>
            <td width=\"20%\">$variable3</td>
            <td width=\"5%\">$variable4</td>
            <td width=\"10%\">$variable5</td>
            <td width=\"20%\">$variable6</td>
            <td width=\"20%\">$variable7</td>
            </tr>
            </table>
           
    <p> ;;</p></td>
            </tr>
            </table>
         <br>";
        CloseTable();
   }


How do I edit that so that the results display more than one record all within just one table. i.e if there are 3 records returned then each record is in its own table so 3 tables show up within my nuke site. I want it so if there was 3 results returned, all 3 would display under 1 table.

WOW PHP is hard, lol

Any ideas anybody?

Cheers for your time.

NOJ75



_________________
PHP Super NooB
Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum