Solved

using as2 and php to record ip addresses

Posted on 2009-07-09
6
354 Views
Last Modified: 2013-11-11
i just wanna record the ip address of any clicking a button. can i simply use this?:

on (release) {
      _root.sendAndLoad("visit.php", this, "POST");      
}

there are no errors on this AS2 code. but i'm not getting anything sent via email nor loaded on my server. what am i doing wrong? thanks.

btw, the config.php works (got stuff working from before) and here's the php code:
<?php
 
    include "config.php";
 
	$to 		= "info@mysite.com";
	$sFrom		= "info@mysite.com";
	$header 	= "From: MYSITE2010 Visit Tracker<" . $sFrom . ">\r\n";
 
	$sIp	= $_SERVER ['REMOTE_ADDR'];
 
	$sQuery = "SELECT IDREC FROM tblVisit ORDER BY IDREC DESC LIMIT 1";
	$rResult = mysql_query ($sQuery, $link);
 
	$row = mysql_fetch_assoc($rResult);
 
	$IDREC  = 1;
 
	if (!empty($row)) {
		$IDREC = (int)$row['IDREC'] + 1;
	}
 
	$sQuery = "INSERT INTO tblVisit SET IDREC=" . $IDREC . ", IPADDRESS='" . $sIp . "', DATETIME= '" . date(DATE_RFC822) . "'";
	mysql_query ($sQuery);
 
	$subject	= "MYSITE2010 Visit Made";
	$body 		= "New visit details : \n\nIP Address : " . $sIp . "\n\nDate :" . date(DATE_RFC822);
 
	mail ($to, $subject, $body, $header);
		
	echo("true");
?>

Open in new window

0
Comment
Question by:ironpen45
  • 3
  • 2
6 Comments
 
LVL 6

Accepted Solution

by:
courtthree earned 100 total points
ID: 24811631
I think your sendAndLoad call might be the problem.

I'm just gonna write a snippet for you to try:
// Put this on the root
var lvSend:LoadVars = new LoadVars();
var lvReceive:LoadVars = new LoadVars();
 
function callLV():Void {
	lvSend.sendAndLoad("visit.php", lvReceive, "POST");
};
 
// Amend your button script to this
on (release) {
      _root.callLV();      
}
 
// Also, check your file path in that the swf, its HTML container 
// and the script are all in the same directory

Open in new window

0
 
LVL 3

Assisted Solution

by:DerkArts
DerkArts earned 25 total points
ID: 24811706
courtthree is right.

Secondly, you can log if the POST came in by using the attached code:

Thirdly, take a look at your mysql, not sure what your doing there, but i recommend a google search for "ON DUPLICATE KEY UPDATE" that will save you some unneeded lines.

Also, check that you have a smtp server running to send the email, check my snippet

ob_start();
var_dump($_POST);
$log = ob_get_clean();
error_log($log, 3, "./error.log");
 
//for the mail command, needs php 5
 if(!mail ($to, $subject, $body, $header)){
    ob_start();    
   print_r(error_get_last());
   $log = ob_get_clean();
   error_log($log, 3, "./error.log");
}

Open in new window

0
 
LVL 6

Expert Comment

by:courtthree
ID: 24811712
Nice one DerkArts, that looks wicked.
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 3

Expert Comment

by:DerkArts
ID: 24811758
I did a lot of flash<>php work, and its really hard to debug it because you dont get any info from you php. This is a simplified version but i ended op writing a specific error class/handler that posted al the errors back to flash, and logged them as wel. Only way to make any sort of progress in complex php<>flash stuff.
0
 
LVL 6

Expert Comment

by:courtthree
ID: 24811764
Well done mate.
0
 

Author Closing Comment

by:ironpen45
ID: 31601468
the moneyshot was courtthree. Derk, my smtp setting are already working, but you reminded me of something else. thx to both of you! works like charm!
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Display Calender only  When events is scheduled in Worpdress? 1 23
php extract($_REQUEST) 5 47
000webhost.com default error log 1 28
PHP Form Calculate Total Price 10 41
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question