Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
Need advice for password protected database
Old 10-06-2009, 12:27 AM Need advice for password protected database
Junior Talker

Posts: 1
Name: Laura
Trades: 0
Hi, I need some advice on a new database I am going to start working on. I need to be able to make information available to about a dozen different people. The database will contain info on milk producers' milk quality statistics. I will need one administrator who can access all info in the database and about 10 user accounts that will need to access only the info for their own farm.

I have created several websites but my experience with databases is limited. If anyone here can help point me in the right direction to get started with this, I'd appreciate it.
Laura228 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-07-2009, 09:52 AM Re: Need advice for password protected database
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Hello Laura, and welcome to webmaster-talk.com.

That's a rather large question you are asking here.
I'll try to cover it at best.

To begin with, you need to be able to lay down the flow of this milk informations. How are they constructed, and how should tehy be presented.

For example, I suppose that there are going to be a list of producers and X tests for each producers with the results.

This could be presented that way:


The 1/N next to the tables represent how many relations can be there.
From Producers to the tests, there is N tests (virtually any number) to 1 producer.
The TestingDate field will serve to separate each testing batch, and to keep an history of the milk quality.

That covers a simple DB layout, but it looks enough given what you explained before.

As for the site itself, you will need a server side language to query the database.
Be it PHP or ASP, as you prefer.

The layout here is realtively simple:
1) set-up an authentication page
2) create 1 page to list the entries in the database, possibly filtered by producers
3) create a page to modify the producer infos
4) create a page to insert new tests results

Have the page 2, 3 and 4 to check in a session for an indication that the users is correctly logged, or send him back to the login page.
I'd do something like this, in PHP:

Login:
PHP Code:
<?
$_SESSION
['logged']=False;
if(
sizeof($_POST)>0){
    
$uname=isset($_POST['username'])?trim(addslashes($_POST['username'])):null;
    
$pwd=isset($_POST['pwd'])?trim(addslashes($_POST['pwd'])):null;
    
$q="select * from users where username='$uname' and pwd='$pwd'";
    
$r=mysql_query($q);
    if(
mysql_num_rows($r)>0){
        
//we have found a user with the given username and password, we go to the main list page
        
$_SESSION['logged']=true;
        
header('location:/displayList.php');
        exit();
    }
}
?>
<html>
    //The form code here, with an action post to itself
list:
PHP Code:
<?php
if( (!isset($_SESSION['logged'])) || ($_SESSION['logged']==false) ){
    
//the user is not authenticated, redirect to the login
    
header('location:/login.php');
    exit();
}

$producerId=null;
if(
sizeof($_POST)>0){
    
//The user wants to filter the list
    
$producer=trim(addslashes($_POST['producerId']));
    
$filter="and p.ProducerId=$producerId";
}
$q="Select * from Producers p inner join TestAttributes t on t.ProducerFk=p.ProducerId where 1=1 $filter order by p.Name"
$r=mysql_query($q);
?>
<html>
    <!-- the page goes here -->
    <table>
        <tr>
            <th>field1</th>
            <th>field2</th>
            <th>field3</th>
            <th>field4</th>
        </tr>
        <?php
        
foreach($o=mysql_fetch_object($r)){
            
//we output the query result
            
echo "
        <tr>
            <td>
{$o->field1}</td>
            <td>
{$o->field2}</td>
            <td>
{$o->field3}</td>
            <td>
{$o->field4}</td>
        </tr>
"
;
        }
        
?>
And so on.
It's not terribly complicated, it's just time consuming.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to Need advice for password protected database
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.10555 seconds with 12 queries