freshJet Posted May 15, 2012 Report Share Posted May 15, 2012 I am creating an external application and I need to incorporate all pilot names, codes and passwords for a chat system. $users=array(); $users[]=array("FRX0001 John Doe","password123"); Above is part of my code. Basically, I need PHP to get the pilot codes, names and passwords to go in that array. And do I use the usual PHP dbconnect? Quote Link to comment Share on other sites More sharing options...
freshJet Posted May 15, 2012 Author Report Share Posted May 15, 2012 Adding to this I could do: $codename = bla bla; $password = bla bla again; $users=array(); $users[]=array("$codename","$password"); Would a foreach loop work? Quote Link to comment Share on other sites More sharing options...
Tom Posted May 15, 2012 Report Share Posted May 15, 2012 Write an SQL statement to select pilot.username, pilot.password, pilot.airlineid and airline.airlinecode where airline.airlineid = pilot.airlineid (because I don't think airline code is stored in pilot table, that would be super inefficient). Then you mysql_fetch_array() your query and voila, array. Quote Link to comment Share on other sites More sharing options...
freshJet Posted May 15, 2012 Author Report Share Posted May 15, 2012 And how would I do that? Quote Link to comment Share on other sites More sharing options...
Sava Posted May 15, 2012 Report Share Posted May 15, 2012 I will try and write the entire code for you today Quote Link to comment Share on other sites More sharing options...
freshJet Posted May 15, 2012 Author Report Share Posted May 15, 2012 Do you mean like: SELECT pilot.username, pilot.password FROM phpvms_pilots ? Quote Link to comment Share on other sites More sharing options...
freshJet Posted May 15, 2012 Author Report Share Posted May 15, 2012 Thanks Sava Quote Link to comment Share on other sites More sharing options...
Sava Posted May 15, 2012 Report Share Posted May 15, 2012 I am afraid I possibly won't finish it today. Some RL issues popped up. I will try and write a short referance on how you can do it yourself later. I will try and do it this evening or tomorrow Quote Link to comment Share on other sites More sharing options...
freshJet Posted May 15, 2012 Author Report Share Posted May 15, 2012 OK no problem 1 Quote Link to comment Share on other sites More sharing options...
Sava Posted May 15, 2012 Report Share Posted May 15, 2012 Just got 15 free minutes. It would be good if you can explain in detail on what you actually want to do with the data as I can maybe do a different approach. If you only want to have a loginscript that checks for the user info, it can be done more easily with something like (considering you got the username and password entered in the form, stripped them of anything that can hurt your website and loaded them into variables) $q=mysql_query("SELECT * FROM phpvms_pilots WHERE pilotid='$id_entered' AND password='$pass_entered'"); $count=mysql_num_rows($q); If( $count == 1) { // do what you want here } else{ echo "The login info is not correct etc"; though you should check how phpvms stores passwords, they are hashed and have a salt so you have to acount for that also. If you just want the arrays you can do a query like SELECT * FROM phpvms_pilots and than do while($rows=mysql_fetch_array(your query)) $ids[]=$rows['pilotid']; Etc With that you can get a specific id. For example echo $ids['0'] would show you the id that is first in the table. The second script should work, but I am not sure as I can't check ATM. If you don't get anywhere by the time I am available, I will try and help. Quote Link to comment Share on other sites More sharing options...
Moderators Kyle Posted May 16, 2012 Moderators Report Share Posted May 16, 2012 Just to warn, you need to be aware that MySQL Injections is likely possible if you doing something out of phpVMS. Do some research on that and you'll see a few things to prevent MySQL injections out of a external login form. For the passwords, phpVMS uses md5, but there's salt inside the md5. Example... $hash = md5($password . $userinfo->salt); if ($hash == $userinfo->password) { //okay, password is good return true; } else { //nope, password is wrong... return false; } Quote Link to comment Share on other sites More sharing options...
freshJet Posted May 18, 2012 Author Report Share Posted May 18, 2012 OK it will be for a chat system (like live chat). So, here's the process: 1. A login form to display which the pilot would login like he would on the site 2. If correct, he is redirected to the chat page and his username will be displayed as [pilot code] [name] e.g FRX0001 John Doe I don't want to put too much code here. Quote Link to comment Share on other sites More sharing options...
Sava Posted May 18, 2012 Report Share Posted May 18, 2012 I am very busy and I am not sure when I will be able to work on the code. But when I get time, I will try. I am new to PHP so it might take time Quote Link to comment Share on other sites More sharing options...
freshJet Posted May 19, 2012 Author Report Share Posted May 19, 2012 Same here that's the reason Quote Link to comment Share on other sites More sharing options...
Tom Posted May 19, 2012 Report Share Posted May 19, 2012 Surely this can just be integrated into phpVMS as a module? Then no additional login is required. 1 Quote Link to comment Share on other sites More sharing options...
Sava Posted May 19, 2012 Report Share Posted May 19, 2012 I thought so too but he says he wants a stand alone application Quote Link to comment Share on other sites More sharing options...
freshJet Posted May 20, 2012 Author Report Share Posted May 20, 2012 The reason I don't want it integrated is that it will be used in the FS Kneeboard or on a mobile phone or iPad, Android Tablet etc Quote Link to comment Share on other sites More sharing options...
Tom Posted May 20, 2012 Report Share Posted May 20, 2012 The reason I don't want it integrated is that it will be used in the FS Kneeboard or on a mobile phone or iPad, Android Tablet etc action.php Quote Link to comment Share on other sites More sharing options...
freshJet Posted May 20, 2012 Author Report Share Posted May 20, 2012 But what would the code be? 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.