jubalbarca
Programmer
I have this AJAX-linked PHP file, which gets a username input by the user, checks if it matches the list it has, then sends back a variable to tell the program what to do next (it only offers the log in option if the name matches).
My problem is linking tis into an SQL table of my users. I have the following table (it's not actually screwed up, but the SQL monitor program won't go fullscreen)
I need to be able to replace the UserNames array in the code with the names loaded from the SQL table (the Array already has both usernames currently in the table I know, but that's for testing purposes as well, and I'm going to write a small script to allow new users to register into the table).
Is this possible, and how can I go about it? I'm only a Javascript specialist really, this is new territory for me...
Many thanks
Code:
<?php
// retrieve the user name
$name = $_GET['name'];
// generate output depending on the user name received from client
$userNames = array('JAMES', 'BUBBLES', 'SUDOBAAL');
header('Content-Type: text/javascript');
if (in_array(strtoupper($name), $userNames))
echo json_encode("1");
else if (trim($name) == '')
echo json_encode("2");
else
echo json_encode("3");
?>
My problem is linking tis into an SQL table of my users. I have the following table (it's not actually screwed up, but the SQL monitor program won't go fullscreen)
I need to be able to replace the UserNames array in the code with the names loaded from the SQL table (the Array already has both usernames currently in the table I know, but that's for testing purposes as well, and I'm going to write a small script to allow new users to register into the table).
Is this possible, and how can I go about it? I'm only a Javascript specialist really, this is new territory for me...
Many thanks