corruptcity || skalman Posted February 15, 2011 Share Posted February 15, 2011 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 Quote Link to comment Share on other sites More sharing options...
sniko Posted February 15, 2011 Share Posted February 15, 2011 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 Quote Link to comment Share on other sites More sharing options...
Danny696 Posted February 15, 2011 Share Posted February 15, 2011 That wont work snikzzz ^.^ Forgot to open the mysqllllll :) Quote Link to comment Share on other sites More sharing options...
Blade Maker Posted February 15, 2011 Share Posted February 15, 2011 He prob assumed that the guy was smart enough to do it himself. Quote Link to comment Share on other sites More sharing options...
corruptcity || skalman Posted February 15, 2011 Author Share Posted February 15, 2011 no i have to follow the UML diagrams i created for it and i ended up with 2 tables for the end users clients and technicians Quote Link to comment Share on other sites More sharing options...
Danny696 Posted February 15, 2011 Share Posted February 15, 2011 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 :) Quote Link to comment Share on other sites More sharing options...
Equinox Posted February 15, 2011 Share Posted February 15, 2011 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 Quote Link to comment Share on other sites More sharing options...
corruptcity || skalman Posted February 15, 2011 Author Share Posted February 15, 2011 ok thanks for the replies guys look like ill need 2 redisgn the login page :( Quote Link to comment Share on other sites More sharing options...
sniko Posted February 16, 2011 Share Posted February 16, 2011 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 Quote Link to comment Share on other sites More sharing options...
corruptcity || skalman Posted February 16, 2011 Author Share Posted February 16, 2011 its ok i editted the stock v2 login script but had to end up using dual gateways and deviating from my class diagram Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.