Welcome, Guest. Please login or register.
Did you miss your activation email?
02/07/12, 08:25
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  General
| |-+  Flash MX 2004 (Moderators: Flash-db, Musicman, vesa kortelainen, Ronald Wernecke, Andresss, papachan)
| | |-+  PHP ip address
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: PHP ip address  (Read 1147 times)
Ifalldown
Server what's that
*
Posts: 12


View Profile Email
« on: 04/01/10, 18:21 »

I'm designing a login/registration form with the typical user/pasword authentication. What I want to do is also check the ip address as part of the authentication process but running into a problem gathering the ip address. I've tried PHP with no luck. I'm sure the problem is bettween chair and keyboard.

I seen the remoting version on the flash-db which is excellent but I would like to attempt this with PHP first. I'm a baby step type. I've tried all the PHP methods I could muster and hoping maybe one of you have some suggestions.   

For now I'm simply writing to a .text file.
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6161


View Profile WWW Email
« Reply #1 on: 04/02/10, 02:43 »

try this:

$_SERVER['SERVER_ADDR']

The $_SERVER array tells you a lot about this current connection Wink

Have a look into the PHP manual about these arrays - there are some more.
Logged

happy flashing
Cool
Ronald
Ifalldown
Server what's that
*
Posts: 12


View Profile Email
« Reply #2 on: 04/02/10, 07:36 »

Hi Ronald,

The ip address is writing to the .text file already but I can't seem to display the content of the text file.  Here is my PHP;


<?php
 
{
                $filename = "xxx.txt";
          $fp = fopen( $filename,"r");
   fclose( $fp );

   $IP = $REMOTE_ADDR;

   $Input = "IP:$ipaddress<b>$IP</b>";

   $New = "$Input$OldData";

   $fp = fopen( $filename,"w");
   if(!$fp) die("&ipaddress=unable to write $filename ......&");
   fwrite($fp, $New, 100);

   fclose( $fp );
}


   $filename = "xxx.txt";
   $fp    = fopen( $filename,"r");
   $Data    = fread($fp, 100);
   fclose( $fp );
      
   exit;
      
?>

.text file content;

IP:<b>69.14.234.228</b>

AS to retrience the data;

ipData = new LoadVars()
ipData.load("http://xxx.com/address.php",0);







Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6161


View Profile WWW Email
« Reply #3 on: 04/02/10, 11:33 »

hm - if dont write anyhing to output, you will not see soemthing Wink

Code:
echo "data=".$Data;

will wrtie the content to the variable data in your LoadVars object, wher you can process it further, or display in your movie clip
Logged

happy flashing
Cool
Ronald
Ifalldown
Server what's that
*
Posts: 12


View Profile Email
« Reply #4 on: 04/02/10, 22:41 »

Thanks responsding Ronald. I am still unable to retrieve the data from the textfile. Below is the PHP with the "echo" but I'm not sure I'm placing it right or writing the script correctly. Maybe the entire PHP is not complete.

<?php
 
{
                $filename = "xxx.txt";
          $fp = fopen( $filename,"r");
           fclose( $fp );
   
   $IP = $REMOTE_ADDR;
             
   $Input = "IP:$IP";
   $New = "$Input$OldData";

   $fp = fopen( $filename,"w");
   if(!$fp) die("&IP=unable to write $filename ......&");
   fwrite($fp, $New, 100);

   fclose( $fp );
   
   }

{
   $filename = "xxx.txt";
               $fp = fopen( $filename,"r");
          $Data = fread($fp, 100);
   fclose( $fp );
   echo "ID:=".$IP;
         
   exit;
   }
      
?>

I wish I was more advanced but that's wishful thinking. Perhaps you could point out where I'm falling down.
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6161


View Profile WWW Email
« Reply #5 on: 04/03/10, 02:21 »

remove the colon:

"ID=".$IP;

then you will find the IP-Address in your LoadVars as ipData.ID;

Be aware, you have to wait for the data event to be fired, before you can read the variable.

Best to start: look into the loading and saving tutorials - there you'll find everything.
Logged

happy flashing
Cool
Ronald
Ifalldown
Server what's that
*
Posts: 12


View Profile Email
« Reply #6 on: 04/03/10, 09:32 »

Hi Ronald,

Thank you so much for your help, working great!. I'm glad you mentioned the " data event ".
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
anything