Jump to content

Array of pilot codes, names and passwords


freshJet

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • Moderators

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;
}

Link to comment
Share on other sites

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.

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.   Restore formatting

  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.

Loading...
×
×
  • Create New...