Welcome, Guest. Please login or register.
Did you miss your activation email?
05/23/12, 00:29
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  Server side Scripting and Database Support
| |-+  MySQL, PostgreSQL, MS SQL, Access (Moderators: Flash-db, Musicman, Ronald Wernecke, Jorge Solis, Andries Seutens)
| | |-+  Login - Personalisation
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: Login - Personalisation  (Read 3217 times)
Finn Beales
Server what's that
*
Posts: 4



View Profile Email
« on: 03/27/02, 07:25 »

Hi.

First, gotta say your site is a nice discovery! Not much on Flash and dBaseing out there I can tell you.

I have followed your tutorial on Login with MySQL and PHP and all works fine, I'm wanting to tweak this slightly to personalise the site depending on who logs in using different movieclips (MC), instead of different positions of the same MC.

I'm developing a football fan site, and wish to have a login page where a member enters in their club username and password. This is then checked against the dBase and allows that user, if the information is correct, to enter their area of the site. In here I'd like to display their specific club badge and some text about their club.
There are only a certain amount of clubs in the UK, and I would therefore predefine usernames and passwords in the dBase, doing away with the need for a registration page.

I guess I would need to use a set of loadmovieclip commands in a table along with my usernames and passwords in my database, and when a user enters their username and password, the corresponding loadmovie command is passed from the database to my php script which is then passed to Flash in the form of a variable?

EDIT
Hmm thinking about it. I'd need two tables with Username i.e. club being the Primary Key in both. Password, and Command being the other fields in the other tables.
When Username (and a correct password) entered in login, a load.php script retrieves loadmoviclip command from second table according to username which then gets fed to the Flash movie?
How do I do it?!!?

I know what I want to achieve, but am a bit confused about how to go about it!
Can you guys give me any pointers?

Cheers. Finn
« Last Edit: 03/27/02, 08:57 by Finn Beales » Logged
Flash-db
Administrator
Systems Administrator
*****
Posts: 1867



View Profile WWW
« Reply #1 on: 04/04/02, 11:26 »

You can use a couple things.

One way might be to use Cookies - When someone logs in you can set a Cookie so that it will remember who that person is and what club their in.

To set a cookie with PHP you can use something like in either the login or Registration part:

setCookie ("UserName",$UserName, time()+30240000, "/");
setCookie ("ClubName",$ClubName, time()+30240000, "/");

Then both of these cookies will be set in the User's Browsers cache.

To access these cookies all you have to do is reference $UserName or $ClubName in a script and it will automatically find the correct user name and club name from the browser's cache.

Then after you get those values you can have some Actionscript to tell Flash what to do depending on those values.

You could also save the Club name in the database and do basically the same thing - but the user would have to login each time and make a query to the database.
Logged

-Jeff.
BurtonRider1983
Global Moderator
Systems Administrator
*****
Posts: 864

Rider-4-Life

BurtonRider1983
View Profile WWW
« Reply #2 on: 04/06/02, 21:18 »

After your login couldn't you just send a variable to flash that defined the username along with the access granted variable.  Then each time your querried the database it could pass the username.  This way the variable would only remain as long as the browser window with the SWF was open.  That way the user will only have to log in for each session on the site.  If somebody else loads up the page....they will not have free access like with cookies.  Shouldn't this work?
Logged
Finn Beales
Server what's that
*
Posts: 4



View Profile Email
« Reply #3 on: 04/08/02, 04:22 »

I've actually solved the problem now using a databse with one table: username, and club, club being chelsea.swf

Whenever anyone logs in with the username in the same row as chelsea.swf that is passed to Flash and a load movie command loads the relevent movie. Works nicely.

However, as I'm not much of a PHP guru, I was wondering how difficult it would be to modify the Movie and PHP script to encompass a password aswell as a username.
Thus making it ultra secure...

Finn
Logged
Flash-db
Administrator
Systems Administrator
*****
Posts: 1867



View Profile WWW
« Reply #4 on: 04/08/02, 12:01 »

What is your SQL statement now for just the username?

To check for both the UserName and Password it would be something like:

$result = mysql_query("SELECT * FROM $table WHERE UserName = '$UserName AND Password = '$Password''");
Logged

-Jeff.
Finn Beales
Server what's that
*
Posts: 4



View Profile Email
« Reply #5 on: 04/08/02, 12:27 »

That sounds fine and I've been experimenting with such code, however what would my Flash command be, I mean how do I lift two variables from the Flash movie to the database.

What would be the loadvariables command I attach to my login button?

Thanks for your help. It's appreciated.

Finn
Logged
Flash-db
Administrator
Systems Administrator
*****
Posts: 1867



View Profile WWW
« Reply #6 on: 04/08/02, 13:37 »

Well their are a couple, probably the best would be to use the "POST" method.  Such as:

on (release) {

loadvariablesNum("YOurScript.php",0,"POST");

}

This will send all of the variables in your current Movie Clip / Level to the script.  You just have to make sure that the UserName and Password exist for that MC / Level - If not you will have to change some paths around to make sure their getting their.

You could also attach them onto the end of the query string - this is sometimes easier at first to see that the actual variables are going - that would be something like this:

loadvariablesNum("YOurScript.php?UserName"+UserName+"&Password="+Password, 0);

Logged

-Jeff.
Finn Beales
Server what's that
*
Posts: 4



View Profile Email
« Reply #7 on: 04/09/02, 07:45 »

OK,

I'm using your second technique, as I thought it would be along this sort of a line.

I'm using the following PHP scripts to process these variables. Are they OK?
Because when I now click the login button it hangs saying Beginning Login process please wait in the status box??

My database has 5 fields:

ID, Name, Password, Comment and movieClip

Finn

---------------------------------------------------------------------------------------------------------

LOGIN SCRIPT

<?
##The login script accesses the database and checks to see whether your Login name exists. If it does it will select your information from the database and Print it out back to Flash.

##This first line of Code is to load your database variables - The include File should be ##renamed with your database variables.
include ('Include.inc');

##This line of Code changes the name to all UPPERCASE. This is so that the login Name is not ##case sensitive. You can make it case sensitive by leaving this line out.

$Name = strtoupper ($Name);

##This line takes out everything from the $Name variable that is not a captital or lowercase letter or a interger between 0 and 9.  This line is only for security purposes so that users can not enter anything that could disrupt the database. You can take this line out if you want.  Or you can allow users to enter other symbols by including a \ followed by that character right after.

$Name = ereg_replace("[^A-Za-z0-9 ]", "", $Name);

#Connects to the database.
mysql_connect($DBhost,$DBuser,$DBpass);
@mysql_select_db("$DBName");

#The SQL query
$query = "SELECT * FROM $table WHERE Name = '$Name AND Password = '$Password''");
$result = mysql_query($query);

#This just gets the number of rows in the Query - It's just a check to see if the Name exists - If not it prints out an error statement.
$numR = mysql_num_rows($result);

#If the number of rows is not equal to one then it prints out an error statement - Name not in Database.    
   if ($numR == 1) {
   print "Status=Success Login Complete&CheckLog=1";
   }
   else {
   print "Status=Failure - Your name was not found - Please register";
   }

?>

LOAD SCRIPT

<?
##All that this script does is to access the database and pull out the properties of the 3 saved objects in the Movie and also the value of the User's Comment. You really don't need to worry about security or anything else because all that this script is doing is just displaying information.

###This first line of Code is to load your database variables.
include ('Include.inc');

#This line converts name to uppercase so the login is not case sensitive.
$Name = strtoupper ($Name);
$Name = ereg_replace("[^A-Za-z0-9 ]", "", $Name);

###This connects to your database.
mysql_connect($DBhost,$DBuser,$DBpass);
@mysql_select_db("$DBName");

###This is the SQL statement that will get your settings from the Database.
$result = mysql_query("SELECT * FROM $table WHERE Name = '$Name AND Password = '$Password''");

    ##This sets the variables from the Database
    $Comment = mysql_result($result,0,"Comment");
    $movieClip = mysql_result($result,0,"movieClip");
 

#This next bit prints out the value's of the Comment and the positions of the three objects whose properties you want to save. This is the line that Flash will read into the movie.

print "Comment=$Comment&movieClip=$movieClip";
?>
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!