Flash Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignFlash Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 4th, 2013, 09:47 PM
vintage89 vintage89 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 2 vintage89 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 35 m 57 sec
Reputation Power: 0
ActionScript 3 - Actionscript 3 > php > mysql (new flash scene after login successful)

Hi guys,

I'm currently having my final year project now and i really need help as i'm very new to actionscript 3.0 > php > mysql connection. I feel so ridiculous to not know how to solve this "simple login code". I'm not sure whether i should add the code in php or actionscript file. But, here goes...

Currently, after the button is being clicked, a successful message will appear --> print "systemResult=Welcome $username!";.
As you can see from the title of my thread, i want it to go to a new scene instead (in flash). I tried so many ways to do it but sadly, it didn't work. Or mayb i'm just doing it wrong, i don't know. I really need help on this!!! Thanks guys!

[Actionscript]

package actions {

import flash.display.MovieClip;
import flash.events.*;
import flash.net.*;
import flash.text.*;


public class main extends MovieClip {

public function main ():void {

submit_button.buttonMode = true;

submit_button.addEventListener(MouseEvent.MOUSE_DOWN, checkLogin);

username.text = "";
password.text = "*";

}

public function checkLogin (e:MouseEvent):void {


if (username.text == "" || password.text == "") {


if (username.text == "") {

username.text = "Enter your username";

}

if (password.text == "") {

password.text = "Enter your password";

}

} else {

processLogin();

}

}


public function processLogin ():void {

var phpVars:URLVariables = new URLVariables();

var phpFileRequest:URLRequest = new URLRequest("login.php");

phpFileRequest.method = URLRequestMethod.POST;

phpFileRequest.data = phpVars;


var phpLoader:URLLoader = new URLLoader();
phpLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
phpLoader.addEventListener(Event.COMPLETE, showResult);


phpVars.systemCall = "checkLogin";
phpVars.username = username.text;
phpVars.password = password.text;

phpLoader.load(phpFileRequest);

}

public function showResult (event:Event):void {

result_text.autoSize = TextFieldAutoSize.LEFT;


result_text.text = "" + event.target.data.systemResult;

}
}
}

[php] - login.php

<?php

include_once "dbconnect.php";

$username = $_POST['username'];
$password = $_POST['password'];

if ($_POST['systemCall'] == "checkLogin") {

$sql = "SELECT * FROM users WHERE username='$username' AND password='$password'";

$query = mysql_query($sql);

$login_counter = mysql_num_rows($query);

if ($login_counter > 0) {

print "systemResult=Welcome $username!";

} else {

print "systemResult=Invalid User!";

}
}
?>

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignFlash Help > ActionScript 3 - Actionscript 3 > php > mysql (new flash scene after login successful)

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap