naate
%Europe/Berlin %439 %2007, 11:32
Hallo,
Ik volg het boek 'Phpvoor Flash, voor en door onterpers'. Maar nu ben ik dus bezig met het maken van een user login, uit hoofdstuk 2. Alleen steeds als er ingelogd wordt met de goede naam en het bijbehorende wachtwoord, kom je bij de tekst: 'Whoops, You need to supply a username and password'. Dus toen heb ik de kant-en-klare versie gedownload op www.friendsofed.com
Maar die doet precies hetzelfde!
Ik heb die gedownloade versie even op internet gezet: www.lavogue.nl/flash/login.html
Dit PHP script hoort erbij:
<?
// Create and fill username and password arrays.
// We also want to return a custom message for each user so
// we'll fill another array with those messaged
$usernames[] = "Steve";
$passwords[] = "nottelling";
$messages[] = "Welcome, oh masterful one!\nHow are you today?";
$usernames[] = "Matt";
$passwords[] = "itsasecret";
$messages[] = "Hello Sir Matt, knight of the purple jelly table! Did you bring my rubber wallpaper?";
$usernames[] = "Alan";
$passwords[] = "nmof2";
$messages[] = "Ah, hello Alan.\nYou'll be glad to know Chapter 2 is *nearly* finished!";
// Check that a username and password have been passed...
if (!isset($username) || empty($username) || !isset($password) || empty($password)) {
// If not tell Flash movie that we've failed and return error message
print "&result=Fail&errorMsg=" . urlencode("You need to supply a username and password");
exit;
}
// Set a variable so we can indicate whether a match was found or not
$matchFound = false;
// Now we loop through each entry in our arrays looking for a valid match
for ($count = 0; $count < count($usernames) && $matchFound == false; $count++) {
// If username and password matches entry...
if ($username == $usernames[$count] && $password == $passwords[$count]) {
// Get the user's message and indicate we've found a match
$message = $messages[$count];
$matchFound = true;
}
}
// If we found a match...
if ($matchFound) {
// Tell the Flash movie that login was successful and return custom message
print "&result=Okay&message=" . urlencode($message);
} else {
// Otherwise, tell Flash movie we failed
print "&result=Fail&errorMsg=" . urlencode("No match found for username/password");
}
?>
Ik volg het boek 'Phpvoor Flash, voor en door onterpers'. Maar nu ben ik dus bezig met het maken van een user login, uit hoofdstuk 2. Alleen steeds als er ingelogd wordt met de goede naam en het bijbehorende wachtwoord, kom je bij de tekst: 'Whoops, You need to supply a username and password'. Dus toen heb ik de kant-en-klare versie gedownload op www.friendsofed.com
Maar die doet precies hetzelfde!
Ik heb die gedownloade versie even op internet gezet: www.lavogue.nl/flash/login.html
Dit PHP script hoort erbij:
<?
// Create and fill username and password arrays.
// We also want to return a custom message for each user so
// we'll fill another array with those messaged
$usernames[] = "Steve";
$passwords[] = "nottelling";
$messages[] = "Welcome, oh masterful one!\nHow are you today?";
$usernames[] = "Matt";
$passwords[] = "itsasecret";
$messages[] = "Hello Sir Matt, knight of the purple jelly table! Did you bring my rubber wallpaper?";
$usernames[] = "Alan";
$passwords[] = "nmof2";
$messages[] = "Ah, hello Alan.\nYou'll be glad to know Chapter 2 is *nearly* finished!";
// Check that a username and password have been passed...
if (!isset($username) || empty($username) || !isset($password) || empty($password)) {
// If not tell Flash movie that we've failed and return error message
print "&result=Fail&errorMsg=" . urlencode("You need to supply a username and password");
exit;
}
// Set a variable so we can indicate whether a match was found or not
$matchFound = false;
// Now we loop through each entry in our arrays looking for a valid match
for ($count = 0; $count < count($usernames) && $matchFound == false; $count++) {
// If username and password matches entry...
if ($username == $usernames[$count] && $password == $passwords[$count]) {
// Get the user's message and indicate we've found a match
$message = $messages[$count];
$matchFound = true;
}
}
// If we found a match...
if ($matchFound) {
// Tell the Flash movie that login was successful and return custom message
print "&result=Okay&message=" . urlencode($message);
} else {
// Otherwise, tell Flash movie we failed
print "&result=Fail&errorMsg=" . urlencode("No match found for username/password");
}
?>