Can't pass user's IP address into email - Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Webmaster Tech > Programming > PHP Development

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 06-13-2009, 12:12 PM   #1 (permalink)
Junior Member
 
Join Date: Feb 2009
Posts: 3
Default Can't pass user's IP address into email

I have an orderform.php script where my customers can submit orders and I get an email notification with their order details (no financial data is sent).

I get a lot of bogus orders with spam in it. So I detect the users IP address in the orderform and now I want to add a submit button to this HTML notification email that I send to myself so I can click on the submit button (in the email) and call another PHP script that will automatically add the IP address to my BlockIP table. Orderform.php checks early in the script for blocked IPs and tries to match it to the current user who is accessing the form and if it finds a match, it does not display the order form.

I know how to do all of the PHP coding to make this happen but the trouble I am having is setting up the correct structure to make this work - I'm trying to pass the IP address into the email body but that is not working. I'm trying to store the IP address in a hidden HTML component so that when I click on the email Submit button when I get the email, it calls the ACTION script Test.php and I try to grab the value by referencing $frm_hidden_ip. But it's not working, inside the email when I build it in the orderform.php, it gets mailed but the value is empty when it shows up in my inbox.

I can't figure out why this is happening...thanks for any help...

Here is orderform.php

PHP Code:
[left]$php_ip_address = getenv(REMOTE_ADDR); 
$php_To = "me@myisp.com"; 
$php_Headers = "From: me@myisp.com\nReturn-Path: me@myisp.com\nContent-Type: text/html;"; 
$php_Subject = "Order Test"; 
$php_Message = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">'. 
'<HTML>'. 
'<HEAD>'. 
'<TITLE>Order Test</TITLE>'. 
'</HEAD>'. 
'<BODY>'. 
'<FORM NAME="test_form" ACTION="http://www.mysite.com/Test.php" METHOD="post">'. 
'<INPUT TYPE="hidden" NAME="frm_hidden_ip" VALUE="<?php echo $php_ip_address?>">'. 
'<BR>'. 
'<INPUT TYPE="submit" NAME="Submit">'. 
'</BODY>'. 
'</FORM>'. 
'</HTML>'; 
mail($php_To, $php_Subject, $php_Message, $php_Headers);
[/left]
Here is Test.php which is called from orderform.php

PHP Code:
[left]<?php 
$ip 
$frm_hidden_ip// grab the hidden HTML component's VALUE data 
print "IP Address is: $ip"
?> 
[/left]
ramonas001 is offline   Reply With Quote
Sponsored Links
Old 07-05-2009, 03:59 PM   #2 (permalink)
Junior Member
 
Join Date: Jul 2009
Posts: 24
Default Re: Can't pass user's IP address into email

change VALUE="<?php echo $php_ip_address?>" to VALUE="'.$php_ip_address.'"
user24 is offline   Reply With Quote
Old 07-05-2009, 04:04 PM   #3 (permalink)
Junior Member
 
Join Date: Jul 2009
Posts: 24
Default Re: Can't pass user's IP address into email

To expand on that further, it looks like you were originally outputting the page as html with the PHP code embedded in it. Then you wanted to put the html code into a PHP variable, so you threw some ' characters around the HTML. Once you did that, everything within the ' characters became part of the string and the code between <? and ?> would no longer execute. What I did was take the variable that you wanted to put the value of into the HTML and concatenated it with the string.
user24 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 07:41 AM.


Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Webmaster Forums
Web Hosting | Chicago Web Hosting | Web Hosting