Current location: Hot Scripts Forums » Programming Languages » Perl » IP address passing


IP address passing

Reply
  #1 (permalink)  
Old 03-15-06, 12:19 AM
TonysDesigns TonysDesigns is offline
New Member
 
Join Date: Mar 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
IP address passing

Hey people. I currently use a perl script for our contact us form page(seen below). The use from this script comes from an HTML page. I am interested in passing the user's IP address to our form that is emailed to us when the user hits submit. In other words, how can I display the user's Ip address on the "thanks page" AND pass it to our mail we receive?

Here is the code:
Code:
#!/usr/bin/perl
use Cwd;
$cgipath='/www1/makeuptalk.com/cgi-bin';
$ftproot=GetFTPRoot($cgipath);
SetIncludePath($cgipath);
require 'municacgi.cgi';
$scripturl="http://$ENV{'SERVER_NAME'}$ENV{'SCRIPT_NAME'}";
$m_pos=rindex($scripturl, "/");
$cgiurl=substr($scripturl, 0, $m_pos);
$cgipath='/www1/makeuptalk.com/cgi-bin';
$ftproot=GetFTPRoot($cgipath);
$cgipath=FTP2System($cgipath);
$WWW_APPNAME="FormPAL";
$_str_valid="Email=EMAIL&";
ParseForm();
if (defined($FORM{'Submit'})||($FORM{'Trigger'}[0] eq "Submit"))
{
  ValidateForm($_str_valid);
SendMail("Action1", "@{$FORM{'First Name'}}", "@{$FORM{'Email'}}", "EMAILADDYHERE", $cc, $subject, "@{$FORM{'Subject'}}", "", "");
  PostUrl("Action2", 0, "", "http://www.makeuptalk.com/contact/thanks.php");
  exit(0);
}
Info();
 
sub SetIncludePath 
{ 
my($m_cgipath)=shift; 
 
	$m_cgipath="$ftproot/$m_cgipath" if ($m_cgipath =~ /^\//); 
	$m_cgipath=~ s/\\/\//g; 
	$m_cgipath=~ s/(\/)+/\//g; 
	pop(@INC); 
	push(@INC, $_) if ($_ ne '.'); 
	push(@INC, "$m_cgipath"); 
	push(@INC, "."); 
	$cc = qw(EMAILADDYHERE);
	$subject = qw(From_MakeupTalk_Contact_Us_page);

} 
 
sub GetCGIPath 
{ 
my ($m_cgipath)=shift;  
my ($m_cwd);	  
	if ($ENV{'PATH_TRANSLATED'} ne "") 
	{  
		$m_cwd=$ENV{'PATH_TRANSLATED'};  
		$m_pos=rindex($m_cwd, "/");  
		$m_pos=rindex($m_cwd, "\\") if ($m_pos<0); 
		$m_cwd=substr($m_cwd, 0, $m_pos);  
	}elsif ($ENV{'SCRIPT_FILENAME'} ne "")  
	{ 
		$m_cwd=$ENV{'SCRIPT_FILENAME'};  
		$m_pos=rindex($m_cwd, "/");  
		$m_pos=rindex($m_cwd, "\\") if ($m_pos<0); 
		$m_cwd=substr($m_cwd, 0, $m_pos);  
	}else 
	{  
		$m_cwd=getcwd();  
	}  
	$m_cwd=~ s/\\/\//g;  
	$m_cwd=~ s/(\/)+/\//g;  
	return $m_cwd; 
} 
 
 
sub GetFTPRoot 
{ 
my ($m_cgipath)=shift;  
my ($m_cwd);	  
 
	$m_cwd=GetCGIPath(); 
 
	$m_cgipath=~ s/(\/)+/\//g;   
	$m_pos=rindex($m_cgipath, "/");  
	$m_pos=rindex($m_cgipath, "\\") if ($m_pos<0); 
	$m_cgipath=substr($m_cgipath, 0, $m_pos) if ($m_pos==(length($m_cgipath)-1)); 
 
	if (length($m_cgipath)>=length($m_cwd)) 
	{ 
		return ""; 
	}elsif ($m_cwd=~/($m_cgipath)$/)   
	{   
		return $`;   
	}elsif ($m_cwd=~/($m_cgipath)\//)   
	{   
		return $`;   
	}else 
	{  
		return $m_cwd;   
	}  
}
Many Thanks
Reply With Quote
  #2 (permalink)  
Old 03-15-06, 04:41 PM
Millennium's Avatar
Millennium Millennium is offline
Wannabe Coder
 
Join Date: Nov 2003
Posts: 136
Thanks: 0
Thanked 0 Times in 0 Posts
you can use $ENV{'REMOTE_ADDR'} to get the users IP address.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
IP Address Search Engine Using AJAX and PHP TheJohnDoe2005 General Advertisements 0 01-18-06 08:11 PM
IP Address in Hidden Box new2php PHP 3 10-19-05 10:21 PM
php and ip address spidadesign PHP 0 05-16-05 05:05 PM
Refresh IP Address thorchan Visual Basic 0 04-16-05 02:30 AM
Regular Expression IP Address Replacement CMIVXX PHP 3 11-20-04 07:27 AM


All times are GMT -5. The time now is 04:09 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.