Beginner Programming
 
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 ForumsOtherBeginner Programming

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, 04:01 AM
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
Unhappy Actionscript 3.0 > 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 new to actionscript 3.0 > php > mysql connection. I feel so ridiculous to not know how to solve this "simple login code". So, 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. 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
  #2  
Old January 4th, 2013, 03:49 PM
portcitysoftwar portcitysoftwar is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 163 portcitysoftwar User rank is Sergeant (500 - 2000 Reputation Level)portcitysoftwar User rank is Sergeant (500 - 2000 Reputation Level)portcitysoftwar User rank is Sergeant (500 - 2000 Reputation Level)portcitysoftwar User rank is Sergeant (500 - 2000 Reputation Level)portcitysoftwar User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 13 h 18 m 54 sec
Reputation Power: 17
I don't do fish but you will get answer much quicker by placing this in the correct forum.
Quote:
Originally Posted by vintage89
Hi guys,

I'm currently having my final year project now and i really need help as i'm new to actionscript 3.0 > php > mysql connection. I feel so ridiculous to not know how to solve this "simple login code". So, 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. 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 ForumsOtherBeginner Programming > Actionscript 3.0 > 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