Programación Web y Scripting > Flash / ActionScript

 problema AS Y PHP

(1/1)

thebcn:
Hola Buenas noches
necesito ayuda con flash y actionscript, y php
uso smart fox server para hacer un juego multiplayer,

el problema es que el script del php era para recojer los usuarios que estaban en un array y decia que la base de datos la tenias que hacer tu y cambiar el script

el codigo de flash es

--- Código: Text ---import it.gotoandplay.smartfoxserver.* stop()   //----------------------------------------------------------// Setup global variables//----------------------------------------------------------var stageW:Number = 700var stageH:Number = 490 // hide semi-transparent panel// used when a dialog box is showndisabler._visible = false // isBusy is true when the application// is requiring input through a dialog box// When true all other controls are temporarily disabled_global.isBusy = false // An event queuevar evtQueue:Array = []  //----------------------------------------------------------// Setup global variables//----------------------------------------------------------showLogin(false)status_txt.text = "Connecting..."  //----------------------------------------------------------var ip:String       = "ipserver"var port:Number     = 9339var zone:String     = "simpleChat"  //------------------------------------------------------------------// NOTE:// Change this url to your local or online webserver and poin it to// the webpage that verifies the login and password.// You will receive 2 POST variables called "login" and "pass"//// The server should respond with a "res" variable:// res=OK (if the user was recognized)// res=KO (if login failed)//------------------------------------------------------------------var serverPage:String   = "login.php"var serverIn:LoadVars   = new LoadVars()var serverOut:LoadVars  = new LoadVars()  var smartfox:SmartFoxClient = new SmartFoxClient()smartfox.debug = true smartfox.onConnection = handleConnectionsmartfox.connect(ip, port)  //----------------------------------------------------------// Handle connection response from server//----------------------------------------------------------function handleConnection(success){    if (success)    {        status_txt.text = "Connected, please login:"        showLogin(true)        butt_login.onRelease = validateLogin    }    else    {        status_txt.text = "Can't connect!"    }} //----------------------------------------------------------// Send login data to the server page//----------------------------------------------------------function validateLogin(){    if (login_txt.text.length > 0 && pwd_txt.text.length > 0)    {        serverOut.name = login_txt.text        serverOut.pass = pwd_txt.text        serverOut.sendAndLoad(serverPage, serverIn, "post")    }}   //----------------------------------------------------------// Handle the PHP server login response//----------------------------------------------------------serverIn.onLoad = function(success){    if (success)    {        if (this.res == "OK")        {            sendLogin()        }        else        {            var win:MovieClip = showWindow("errorWindow")            win.errorMsg.text = "Wrong name or passord"        }    }    else    {        var win:MovieClip = showWindow("errorWindow")        win.errorMsg.text = "Connection failed"    }}   //----------------------------------------------------------// Send login params to the server// server.login(zone, nickName, password)//----------------------------------------------------------function sendLogin(){    if (!_global.isBusy)        smartfox.login(zone, login_txt.text, pwd_txt.text)}   //----------------------------------------------------------// Handle login response from server//----------------------------------------------------------smartfox.onLogin = function(resObj:Object){    if (resObj.success)    {        // Login Successfull        _global.myName = resObj.name    }    else    {        // Login Failed        _gloabl.isBusy = true                // Show an error window        var win = showWindow("errorWindow")        win.errorMsg.text = resObj.error    }} //----------------------------------------------------------// Handle the onRoomListUpdate here and keep it in the// queue. We'll handle it in the next frame.//----------------------------------------------------------smartfox.onRoomListUpdate = function(o:Object){    evtQueue.push(o)    gotoAndStop("chat")}  //----------------------------------------------------------// Handle unexpected server disconnection//----------------------------------------------------------smartfox.onConnectionLost = function(){    gotoAndStop("connect")}   //----------------------------------------------------------// Show / Hides the login input field and submit button//----------------------------------------------------------function showLogin(bool:Boolean){    butt_login._visible = bool    login_txt._visible = bool    pwd_txt._visible = bool        if (bool)        Selection.setFocus("login_txt")}   //----------------------------------------------------------// Shows a popup window and disables all other controls//----------------------------------------------------------function showWindow(linkageName:String):MovieClip{    _global.isBusy = true        userList_lb.setEnabled(false)    disabler._visible = true        var win = _root.attachMovie(linkageName, linkageName, 9999)            win._x = (stageW / 2) - (win._width / 2)    win._y = (stageH / 2) - (win._height / 2)        return win}   //----------------------------------------------------------// Hides a popup window and re-enable the controls//----------------------------------------------------------function hideWindow(wName:String){    this[wName].removeMovieClip()    disabler._visible = false    _global.isBusy = false        userList_lb.setEnabled(true)}  
y el codigo del login.php:

--- Código: Text ---<?php$dbhost="localhost";  $dbusuario="myuser"; $dbpassword="mypass";$db="mydb";$conexion = mysql_connect($dbhost, $dbusuario, $dbpassword);mysql_select_db($db, $conexion);$usuario = $_POST["name"];$pass = md5($_POST["pass"]);$consulta_usuario ="SELECT * FROM usuarios WHERE nick = '$usuario' AND password = '$pass'";$result = mysql_query($consulta_usuario) or die("Couldn't execute query.");$num_rows = mysql_num_rows($result); if($num_rows == 0){ $res = "res=KO";}else{if($num_rows > 0){ $res = "res=OK";}mysql_close($conexion);}?> 
Muchas Gracías
Saludos.

Navegación

[0] Índice de Mensajes

Ir a la versión completa