473,399 Members | 4,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Split two different users on log in page

Hi
I need to have two different users LOG in on to my page.Each of them have their own tables to where their data is stored and I have a separate users table which has username and password,then the username is suposed to link to the other two tables,I do register to each table then when using that data to LOGIN it doesnt work.

Is there a way I must do it.Here's my login code.The customer must see a different page from the supplier when logged on.

Thanx

<?php
$connection = mysql_connect("localhost", "root", "phpmysql");
$select_db = mysql_select_db("procdb", $connection);
$query = mysql_query ("SELECT cust_code, cust_username, cust_pswrd FROM customer", $connection);
$query = mysql_query ("SELECT supp_code, supp_email, supp_pswrd FROM supplier", $connection);


if(isset($_COOKIE['ID_my_site']))

//if there is, it logs you in and directes you to the members page
{
$name = $_COOKIE['ID_my_site'];
$pass = $_COOKIE['Key_my_site'];
$check = mysql_query("SELECT cust_pswrd FROM customer WHERE cust_username = '$cust_username'")or die(mysql_error());
//$check = mysql_query("SELECT cust_username,cust_pswrd FROM customer WHERE cust_username = '$cust_username'")or die(mysql_error());
while($info = mysql_fetch_array( $check ))
{
if ($pswrd != $info['cust_pswrd'])
{
}
else
{
header("Location: welcome.php");

}
}
}

//if the login form is submitted
if (isset($_POST['submit'])) { // if form has been submitted

// makes sure they filled it in
if(!$_POST['name'] | !$_POST['pass']) {
die('You did not fill in a required field.<a href=mysql_connection1.php>back</a>');
}
// checks it against the database

if (!get_magic_quotes_gpc()) {
$_POST['email'] = addslashes($_POST['email']);
}

$check = mysql_query("SELECT cust_pswrd FROM customer WHERE cust_username = '".$_POST['name']."'")or die(mysql_error());
$check1 = mysql_query("SELECT supp_pswrd FROM supplier WHERE supp_name = '".$_POST['name']."'")or die(mysql_error());
//Gives error if user dosen't exist
$check2 = mysql_num_rows($check);
$check3 = mysql_num_rows($check1);
//$check2 = mysql_num_rows($check1);

if ($check2 && $check3 == 0) {
die('That user does not exist in our database.

<a href=reg1.php>Click Here to Register</a>');
}
while($info = mysql_fetch_array( $check ))
{
$_POST['pass'] = stripslashes($_POST['pass']);
$info['cust_pswrd'] = stripslashes($info['cust_pswrd']);
$info['supp_pswrd'] = stripslashes($info['supp_pswrd']);
$_POST['pass'] = md5($_POST['pass']);

//gives error if the password is wrong
if (($_POST['pass'] != $info['cust_pswrd'])|($_POST['pass'] != $info['supp_pswrd'])) {
//if (md5($_POST['pass'] ,$info['cust_pswrd'] ==$info['cust_pswrd'])){


//if ($_POST['pass']!= $info['cust_pswrd']) {
echo $_POST['pass']."<br>\n";
echo $_POST['$info']."<br>\n";
die('Incorrect password, please try again.<a href=mysql_connection1.php>Click Here </a>');
}
else
{

// if login is ok then we add a cookie
$_POST['name'] = stripslashes($_POST['name']);
$hour = time() + 3600;
setcookie(ID_my_site, $_POST['name'], $hour);
setcookie(Key_my_site, $_POST['pass'], $hour);

//then redirect them to the members area
$query = mysql_query ("SELECT supp_code, supp_email, supp_pswrd FROM supplier", $connection);
header("Location: welcome.php");
}
}
}
else
{

// if they are not logged in
?>

<TR>
<TD><IMG height=115 src="resources/visitorsBanner.png" width="100%"></TD>
</TR>
<form action="<?php echo $_SERVER['../test/PHP_SELF']; ?>" method="post">
<table border="0">
<tr><td colspan=2><h1>Login</h1></td></tr>
<tr><td>Username:</td><td>
<input type="text" name="name" maxlength="40">
</td></tr>
<tr><td>Password:</td><td>
<input type="password" name="pass" maxlength="50">
</td></tr>
<tr>
<td colspan="2" align="right"> <input type="submit" name="submit" value="Login">
<input type="Reset" value="Clear Form" ></td>
</tr>
<tr>
<td>
<a href=reg1.php>Customer Register</a>
<a href=reg2.php>Supplier Register</a>
</td>
</tr>
</table>
</form>

<?php
}

?>
Sep 11 '06 #1
0 1993

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Will McGugan | last post by:
Hi, I'm curious about the behaviour of the str.split() when applied to empty strings. "".split() returns an empty list, however.. "".split("*") returns a list containing one empty string. ...
16
by: Geoff Cox | last post by:
Hello, I publish some web pages using large fonts and would like to give the user the opportunity to print the pages using a smaller font. I believe that this is possible using different style...
3
by: Xah Lee | last post by:
Split File Fullpath Into Parts Xah Lee, 20051016 Often, we are given a file fullpath and we need to split it into the directory name and file name. The file name is often split into a core...
8
by: J Stoodley | last post by:
I am in a learning curve right now, and want to become well aquanted with VB.NET. So, I have two questions. 1 is technial the other is resource related. 1. I need to strip a single character...
2
by: gordonjones | last post by:
I have users on different computers getting the error message "could not update;currently locked" when trying to leave identical fields after making a change on the same form but on different...
9
by: MrHelpMe | last post by:
Hello again experts, I have successfully pulled data from an LDAP server and now what I want to do is drop the data into a database table. The following is my code that will insert the data but...
4
by: kaplan.gillian | last post by:
Hi everyone, I currently have an Access database that includes quite a few long memo fields. When I create a report of my data, Access does not allow the memo fields to be split with the page...
21
by: =?ISO-8859-1?Q?Fad=A5?= | last post by:
Hello guys, I want to do kinda of an A/B split testing on a website I run. I just created a new version but I need to keep both version running and see which one will perform better. First, I'm...
1
by: Gordon | last post by:
I've been looking into including a system to allow logging of diffs so users can view different versions of a file and roll it back to an earlier version. After a lot of faffing with PHP diff...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.