FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


create swishmax Login with phpbb db





PriDe
I'm looking for a way tocreate a flash movie using swishmax to be able to connect to the phpbb database and check if that specific username and password exist in the forum database and return int answer.

Found the following tutorial but this one has got specific tables and variables. I would like to use the phpbb username and password.....any help would be appreciated. 10ks

Code:
Hey guys,

First you will need two textboxes, with the VARIABLE names of user and pass(I always keep the names relevant, to help remember)

Second, I made a little submit button, with only an onpress gotoandplay(13)
(Actually, I used a label)
Actual code:
Code:
on (release,keyPress("<Enter>")) {
    gotoAndPlay("checklog");
}



Now we will start with the code for the label and login, and then go from there.

Code:
onFrame (13) {
    setLabel("checklog");
    this.loadVariables("login.php",'POST');
}
onFrame (19) {
    if (login == 'true') {
        gotoAndPlay("nothing");
        _root.user = user;
    } else if (login == 'false') {
        res = "Try Again";
    }
}


Line 1: Do this on frame 13(Kinda self explanatory)
2: Set label for my submit button, I use labels to keep things organized
3: I am using loadvariable for a SPRITE, so make sure you group everything as a sprite
4: Close tag
5: On frame 19, The reason I have the delay in here is it takes a little while for php to run through the code and give us back the response, so give it a few frames.
6: You will understand this once we get to php, because the php sends us back a variable &login and then we check that variable.
7: On nothing I have removed what I don't want if the login correctly
8: The reason I do this is because I want to be able to reference the variable user later, to show them their username(You would reference by using _root.user)
9: What? Php says you logged in wrong.
10: This is another textfield with the variable name of 'res', I use this to display the message try again. You can also go to a different frame, anything you want here.

You can include this code in any swishmax file you want. As long as your php file is in the same place, it will work in any swishmax file Smile


Part II: Php

To start things off, you will need a simple mysql table in your database with the fields Username and PASSWORD. These are how they are referenced in this code. Also, the table's name will be login in this example

To create this database:
Code:
CREATE TABLE `login` (
  `Username` varchar(255) default NULL,
  `PASSWORD` varchar(255) default NULL
) TYPE=MyISAM;


Now we can FINALLY get to our php Smile

Code first, explain later Razz(The name is login.php)
Code:
<?php
/*
If you have read the other tutorials, you understand the post, you understand also the connecting to the mysql database, so I will explain the login check only
*/
$user = $_POST['user'];
$pass = $_POST['pass'];
  $dbh=mysql_connect ("localhost", "username", "password") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("dsistu48_forum");

//Regular Login Check, No admin or Banned

$query = "SELECT Username, PASSWORD FROM login WHERE Username = '$user' AND PASSWORD = '$pass' AND position = 'Member'"; //Select the correct row for the username
$rows = mysql_query($query) or die ("You has an Error in login.php; $query.". mysql_error()); //Query the db
$numrows = mysql_numrows($rows);
if($numrows > 0) { //If a row returns..
  echo("&login=true");  //For flash, tells it that login is correct
} else {
die("&login=false");
}
//BELOW CODE IS OPTIONAL
$result = @mysql_query("SELECT Username FROM login WHERE Username='$user'");
  while ( $row = mysql_fetch_array($result)) {
  echo("&user=".$row['Username']); }
?>
vinx_18
You have to check the table for login in phpBB2 first..

Quote:
$dbh=mysql_connect ("localhost", "username", "password") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("dsistu48_forum");
--> change this stuff here to coincide or match to your phpBB2 forum...

Quote:
$query = "SELECT Username, PASSWORD FROM login WHERE Username = '$user' AND PASSWORD = '$pass' AND position = 'Member'";
---. change also this ... you've got to know the login table of phpBB2 forum..

It's a lot of work...gud luck!
Related topics
phpBB transfering
Help Duds
IP Banning
Does anyone know how
How to Make A PHP Portal.
Developing a Login System with PHP and MySQL
Login/PHPBB Intergration [Read]
Does mySQL support BLOB? How?
how do you create a login field with html?
Problem with Mybb :: Changing DB Username
Could someone create a really simple login system???
Login/Register Page
Login system doesn't work
Creating safe persistent login system
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.