This topic is locked

New to PHP

10/24/2007 2:05:22 PM
PHPRunner General questions
R
robbhelt author

I really like this program and I have figured alot of it out on my own, but I am stumped on a few issues.

  1. I have created a mysql database on my web host and I have no problem connecting to it. This database has 15 fields and no primary key.
  2. I have the fields publish via PHP to a website that is http://www.glflow.com (username is robb and pw is robb) if you need to look at it.
  3. I would like to have the ability to create usernames and passwords for each individual table that I create. I would like a page after log in that will do a query that has a drop down box that would allow the user to choose a date and then it filters the date and only brings the table (Like the one I posted) for view.
    I am thinking that if I have many different users then I am going to need to create many different tables and then give each user access to only certain tables.
    It is very hard for me to explain all of this in writing...I can talk better than I explain in print.
    Ask me questions and I can answer them.
    Can all of this be completed with PHPRunner??
    Thanks in advance
    Robb

hax0r 10/24/2007

Instead of multiple tables with different log ins, maybe you should consider one of the following options:
Create a table called Users.

id - int(11) unsigned

username - varchar(25)

password - varchar(50)
Now in your other table, add a column name user_id or whatever

Whenever a user creates a record, insert their id into user_id.
Furthermore, whenever people log in, restrict what they can see in your other table to rows that they created. WHERE id = user_id.
That solution would let everyone see their own records, but no others. Perhaps you want some people to see all records, or some people to see certain people's records. In this case, you could set up a group_id in the Users table... so the Users table looks like
Users

id - int(11) unsigned

group_id - int(11) unsigned

username - varchar(25)

password - varchar(50)
Add the group_id to your other table. And allow people who log in to see their own entries as well as entries put up by other users in the same group. You could even reserve group_id 1 as a master group id (for yourself) and add to the Where clause "OR group_id = 1". This way you could see all entries...
An even better alternative would be to also add a User_Grants table
User_Grants

user_id - int(11) unsigned <-- linked to Users table

group_id - int(11) unsigned
This way you could customize the entries that each user could see.
good luck. don't forget to hash the password with md5 or sha1 or something similar.

R
robbhelt author 10/24/2007

The fact that only 10% of what you said made sense to me shows you exactly how dumb I am..
Here is what I am trying to duplicate...
http://www.impactenergyservices.com
username is sedna_energy

password is flowback
The users are actually companies that go in to see the production on their wells, but they have no business seeing what other companies wells are....
They should also have no ability to do anything but read.
Now on the creation of the tables....There is one person who goes in and updates all of the info on that chart....Then the owner of the well or company can go see what their well is producing...
Flow hand updates info and owner gets to view it.
Not hard in theory but I am not smart.
Robb

Instead of multiple tables with different log ins, maybe you should consider one of the following options:

Create a table called Users.

id - int(11) unsigned

username - varchar(25)

password - varchar(50)
Now in your other table, add a column name user_id or whatever

Whenever a user creates a record, insert their id into user_id.
Furthermore, whenever people log in, restrict what they can see in your other table to rows that they created. WHERE id = user_id.
That solution would let everyone see their own records, but no others. Perhaps you want some people to see all records, or some people to see certain people's records. In this case, you could set up a group_id in the Users table... so the Users table looks like
Users

id - int(11) unsigned

group_id - int(11) unsigned

username - varchar(25)

password - varchar(50)
Add the group_id to your other table. And allow people who log in to see their own entries as well as entries put up by other users in the same group. You could even reserve group_id 1 as a master group id (for yourself) and add to the Where clause "OR group_id = 1". This way you could see all entries...
An even better alternative would be to also add a User_Grants table
User_Grants

user_id - int(11) unsigned <-- linked to Users table

group_id - int(11) unsigned
This way you could customize the entries that each user could see.
good luck. don't forget to hash the password with md5 or sha1 or something similar.

Sergey Kornilov admin 10/24/2007

Robb,
my suggestion is to watch PHPRunner live demos first. Find the demo that is close to what you trying to build and proceed from there. This way you can ask more specific questions and get answers that speak your language.
http://xlinesoft.com/phprunner/livedemo4.htm
Also you can watch PHPRunner tutorials at http://xlinesoft.com/phprunner/php-database.htm

Check those that are related to security settings.
I hope this helps.

R
robbhelt author 10/24/2007

Yeah...Those are great...They show something that the program can do but now HOW to do it.
Sorry I am a bother. I will figure it out and go from there....i just did not want to waste much time, but I will get it worked out.
Hey Hax0r...Thanks for the info and taking the time to help me....I am sure your post will make more sense as I get into this.
Robb

Sergey Kornilov admin 10/24/2007

Actually Flash tutorials show you HOW you can do things.

G
GeddyLee 10/29/2007

Robb,
If you're still having trouble, it seems you might want to learn a little more about SQL too, it seems like that might help you out, but since I'm not sure exactly what you're trying to do it's hard to say for sure.
from what you said, and the example, it doesn't seem like you should be creating new tables to each user. Do a little research about foreign keys and primary keys and find out what they're used for. I can't imagine having a table without primary keys (although perhaps some exist).
Also a quick run down (don't mean this to be insulting, just trying to help)

The Database holds tables, it doesn't have fields, each table belongs to the database. Each tables have fields which identify what sort of data is being held in them. The tables can relate to each other through use of foreign keys.
When you said your database has 15 fields, that kind of made me think you should at least get your terminology straight, if for no other reason than to communicate your troubles.
It sounds like haxor is on the right track, you need a user's table, and then your primary data table that relates information to the user. PHPRunner has some security features, but since I've never used them I couldn't tell you how to. But learn a little about that, and do a little research about SQL, users tables, and foreign keys and you should be closer to your solution.
-Brent