Jump to content
MakeWebGames

Login problem


corruptcity || skalman

Recommended Posts

hi im studyin a foundation degree in ICT atm and 1 of the units im doing is about the internet and WWW where we are tasked with building a helpdesk site but ive come accross with a problem with that both the techies and clients need 2 be able to login to it and im stuck thinking how to get that to work now ive come up with 2 ideas and would like some imput if either or both would work or if you know another way that do it

method 1

basically would be

a select query in the technician table where username and password match

then have

$db->num_rows(query) == 0)

{

false runs query for the clients

}

else

{

true does the $r=$db->fetch_row(query);

}

then the rest

method 2

put both tables in 1 query with a JOIN and in the WHERE have WHERE t.tech_login = $_POST['blah'] AND t.blah = $_POST['blah'] OR c.cust_login = $_POST['blah'] AND c.cust_password

thanks skal

Link to comment
Share on other sites

The following is what i would do;

 

  • Create a table - call it `users`, and add these columns
    • user
    • login_name
    • passcode
    • type - ENUM('client', 'technican') DEFAULT 'client'

    [*] Create the register file, or manually input the data into the database (But in your case a register file, as clients will need to register)

    [*] Create the login file and have the following in it...

    <?php
    
    session_start();
    
    if($_POST)
    {
    	//Secure _POST's
    	$check = mysql_query("SELECT `key`,`type` FROM `users` WHERE `login_name`='{$_POST['login']}' AND `passcode`='{$_POST['passcode']}'");
    	if(mysql_num_rows($check) === 0)
    		{
    			//Not a member
    			//Display Error Message
    			exit;
    		}
    	$r = mysql_fetch_array($check);
    	$link = ($r['type'] == 'client') ? "[url='client.php']Continue[/url]" : "[url='technican.php']Continue[/url]";
    	echo "Welcome {$_POST['login']} 
    
    
    		  [".$link."]";
    	$_SESSION['user'] = $r['key']; //Used for sessions, as this is a login script.
    }
    echo "<form action='' method='post'>
    	Login Name: <input type='text' name='login' length='5' maxlength='15' />
    
    
    	Passcode: <input type='password' name='pass' length='5' maxlength='15' />
    
    
    	<input type='submit' value='Login!'>
       </form>";
    
    ?>

 

Should all work :)

I say should, as it is untested

-sniko

Link to comment
Share on other sites

Hmm;

1) Give them two login 'portals' to the techyys go to one, check the techhy table etc...

2) Check one then the other

I'd persoanlly have done it snikz' way, but for you, id go for the dual portal idea :)

 

If your forum signature fools anyone, please, please let me know.

xD

Link to comment
Share on other sites

Damn, yea i forgot about opening the mysql, my fault.

Anywho, Skalman, you don't have to toally re-design it, just follow what i did but alter it a little, i've probably supplied around 70-80% of it, but if you need any assistance, my msn address is in my signature.

-sniko

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...