Jump to content

Recommended Posts

Hi All,

 

I have the following code in PHP.

 

function login($username,$pass) 
{ 
   GLOBAL $db,$table; 
   $username = trim($username); 
   $pass = md5(trim($pass)); 
           $query = mysql_query("SELECT * FROM $table WHERE userName = '$username' AND userPassword = '$pass'"); 
               return mysql_num_rows($query); 
}

 

Inside the database i have the following fields:

 

userID

userName

userPassword

userMail

userQuestion

userAnswer

userBalance

 

I realise that the query is selecting all these fields from the database, but what i want to be able to do is show the value of userBalance in a dynamic text field inside of Flash.

 

Can anyone suggest how i might be able to go about this?

 

Also i should metion that the code also checks if the users login details are correct, not sure if this affects my ability to alter the PHP code.

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/111113-echoing-php-queries-into-flash/
Share on other sites

This is really a flash question i think..

but to echo the results just do

 

function login($username,$pass) 
{ 
   GLOBAL $db,$table; 
   $username = trim($username); 
   $pass = md5(trim($pass)); 
           $query = mysql_query("SELECT * FROM $table WHERE userName = '$username' AND userPassword = '$pass'"); 
           $row = mysql_fetch_assoc($query)
           echo $row['userBalance'];
               return mysql_num_rows($query); 
}

If i echo the userBalance in this way, would this affect the way the existing code operates. I.E. I need this code not only to check what a particular users balance is and display the correct amount in flash but also to check if the the login details the user has entered are correct?

 

Thanks for your help

<?php
function login($username,$pass) 
{ 
   GLOBAL $db,$table; 
   $username = trim($username); 
   $pass = md5(trim($pass));
   $query = mysql_query("SELECT * FROM $table WHERE userName = '$username' AND userPassword = '$pass'"); 
   $count = mysql_num_rows($query);
   if($count == 0) return $count;
   $row = mysql_fetch_assoc($query)
   echo $row['userBalance'];
   return $count; 
}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.