If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > User Login, check fields from multiple tables

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-23-10, 01:55
Tryphy Tryphy is offline
Registered User
 
Join Date: Feb 2010
Posts: 2
User Login, check fields from multiple tables

Hi friends,
I have a major doubt: Could you please help me with this...

I have a create company form, create project form..
In the create company form, it creates the company name and a company code for it..and in the project form, i have one field as option value, which takes the company name from the company form and populates in and also a project code..In the same create project form, i have 4 other fields as:
user A- name:
User A - pass:

User B - name:
User B- pass :

Which is basically v cannot create a project b4 creating a company.On company can have more than one projects

eg:
C1 - P1 - 2 username, 2 passwords
C2 - P1 - 2 username, 2 passwords
- P2
C3 - P1
- P2
- P3
================================================
I want the company code to be like - 1001 and auto increment:
so what i did was, when creating the company, i create a table for each company with the company name as table name:while doing this, i also insert the values to a standard table "create_company"..in which i have the auto-increment code and company name:

Then when creating project, that particular project details will be entered into that particular company tables...
It all works good for me...
================================================
The project code is 01, 02..
Can v have auto - increment of codes like this..(01,02)..
When i tried and checked my database tables...it takes the value as 1, 2, 3, ....But i need it to be 01,02..

Can it be done ?


Another question is....
In the project form details : we have 4 fields
which is the username and password...which helps user for login access.
I have a user Login page : This has to check from all the company projects that has been created...How do i do a check in it...?

Previously when i have one common table for projects:it works:
the code that i used for checking standard table is below:
The standard table is "company_creator"

Code:
$result = mysql_query("SELECT * FROM company_creator WHERE c_name='$name' AND c_pass = '$pass'");$result1 = mysql_query("SELECT * FROM company_creator WHERE m_name='$name' AND m_pass = '$pass'");if(mysql_fetch_array($result)){$_SESSION['login'] = $name;header("Location: UserA.php");return;}else if (mysql_fetch_array($result1)){$_SESSION['login'] = $name;header ("Location: UserB.php");return;}else$_SESSION['error'] = "Login failed";}header("Location: user_login.php");$result = mysql_query("SELECT * FROM company_creator WHERE c_name='$name' AND c_pass = '$pass'");
$result1 = mysql_query("SELECT * FROM company_creator WHERE m_name='$name' AND m_pass = '$pass'");
if(mysql_fetch_array($result))
{
$_SESSION['login'] = $name;
header("Location: UserA.php");
return;
}
else if (mysql_fetch_array($result1))
{
$_SESSION['login'] = $name;
header ("Location: UserB.php");
return;
}
else
$_SESSION['error'] = "Login failed";
}
header("Location: user_login.php");
But now i have many tables generated as the admin create many companies.....
and inside of each company table, it has 2 username and 2 passwords..
How do i check it ?

I tried something like :but didnt work...
Code:
$table = mysql_query("select company_name from create_company");$sql = mysql_fetch_array("$table");$output = mysql_query("select c_name.$sql,c_pass.$sql from $sql Where c_name ='$name' AND c_pass = '$pass'");$table = mysql_query("select company_name from create_company");
$sql = mysql_fetch_array("$table");
$output = mysql_query("select c_name.$sql,c_pass.$sql from $sql Where c_name ='$name' AND c_pass = '$pass'");
* - where create company is table that i have the auto- increment id and the company name

Can any1 help me with this..?
Thanks in Advance..
Reply With Quote
Reply

Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On