Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

demonrealms

Flash MX, authentication

This topic is 5300 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, I was wondering if it was possible to embed a .SWF file in my webpage that asks for username/password and then have the website use a PHP/MYSQL check through a users database on the server. I sthis possible? If it is how would I go about doing this?

Share this post


Link to post
Share on other sites
Advertisement
I believe you can do this, on a server that supports it, using "flash remoting". I haven't use it myself, but I just know since I helped a guy with some php on it

Is the Flash absolutely needed? Does it control entry to the rest of the animation? If it isn't needed, just use a normal html forms entry.

[edited by - ch1pz on April 11, 2004 11:26:37 AM]

Share this post


Link to post
Share on other sites
unofrtunatly it is needed. Part of my site is just in FLASH, but I need authentication support. If I can just find out how to get the webpage to find out what I typed in the flash textbox I could be good to go from there.

Share this post


Link to post
Share on other sites
Say you have a Flash form with two input boxes named username and password, as well as a submit button. You want the form to then call login.php with its data when the submit button is pressed.

In the submit button''s actionscript put:
loadVariablesNum("login.php", 0, "POST");

Then in login.php you will have two automatically created variables, $username and $password. Running those through a database is standard PHP that I think you should be able to do.

Try simply adding that line to your submit button, then having login.php just contain something like

<HTML>
<BODY>
<?
print $username.", ".$password;
?>
</BODY>
</HTML>

and see if that works. I assume you can take it from there ;-).

Share this post


Link to post
Share on other sites
Now it just opens the website flogin.php and just sits there,
this is my code for the button in the FLASH (textboxes each named username and mypassword)

on(click)
{
loadVariablesNum(getURL("http://www.demonrealmstudios.com/flogin.php", _self), 0, "POST");

enabled=false;
}

And my code for flogin.php is:

<?php
$log = 0;
$dbh=mysql_connect ("localhost", "*******", "******") or die (''I cannot connect to the database because: '' . mysql_error());
mysql_select_db ("demonrea_globaluser");

$sql = "SELECT * FROM users WHERE username = ''$username'' AND
password = ''$mypassword'' "
;
$result = mysql_query($sql, $dbh);
while($row = mysql_fetch_array($result)) {
$user = $row[ ''username'' ];
$auth_lvl = $row[ ''auth_lvl'' ];
if($auth_lvl == 0) {
$log=1;
}else { $log=2;
setcookie("username", $username, time()+60*60*24*30, "/", "www.demonrealmstudios.com", 0);
setcookie("password", $password, time()+60*60*24*30, "/", "www.demonrealmstudios.com", 0);
}
}
mysql_close($dbh);
?>

<html>

<head>
<style type="text/css">
.ipt { border: 1px solid black; font-size: 7pt; }
</style>
<title>Demon Realms Studios®->Login</title>

</head>

<body bgcolor="black" text="white">
<br />
<br />
<br />
<br />
<br />
<br />
<table cellspacing=0 width="450" height="250" align=center border=0>
<tr>
<td background="images/login2.gif" valign=top align=left>
<?php
if($log == 1) {
?>
<center><font color="red">Invaild password</font></center>
Logged in as: <?php echo "$username"; ?><br />
Password tried: <?php echo "$password"; ?><br />
<?php
}
?>
<?php
if($log == 2) {
?>
<br />
<br />
<center>Logged in successfully as: <?php echo "$username"; ?><br />
Your password is: <?php echo "$password"; ?><br /></center>
<?php
}
?>
</td>
</tr>
</table>
</body>

</html>
Does anyone know what I''m doing wrong?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!