Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Can't pass user's IP address into email
Old 06-11-2009, 04:09 PM Can't pass user's IP address into email
Skilled Talker

Posts: 64
Name: Ralph Freshour
Trades: 0
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:
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:
PHP Code:
[left]<?php 
$ip 
$frm_hidden_ip// grab the hidden HTML component's VALUE data 
print "IP Address is: $ip"
?> 
[/left]
__________________
RalphF
Business Text Messaging Services

Please login or register to view this content. Registration is FREE
rfresh is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-11-2009, 04:38 PM Re: Can't pass user's IP address into email
maxxximus's Avatar
Extreme Talker

Posts: 219
Name: Rob
Location: UK
Trades: 0
Bad idea to filter IP addresses. Dynamic IPs mean you could be blocking legitimate customers.

Try incorporating Re-catcha http://recaptcha.net/ and other anti-spam techniques.
maxxximus is offline
Reply With Quote
View Public Profile
 
Old 06-11-2009, 05:43 PM Re: Can't pass user's IP address into email
Skilled Talker

Posts: 64
Name: Ralph Freshour
Trades: 0
rcaptcha will certainly help and I will look into it, but it won't stop the *humans* who are accessing my orderform and sending me bogus orders.

I'd still like to be able to filter on their IP addresses and thus would like to get my code here to work as I envision it...thank you...
__________________
RalphF
Business Text Messaging Services

Please login or register to view this content. Registration is FREE
rfresh is offline
Reply With Quote
View Public Profile
 
Old 06-11-2009, 06:00 PM Re: Can't pass user's IP address into email
Novice Talker

Posts: 9
Trades: 0
PHP Code:
<?php
$php_ip_address 
getenv(REMOTE_ADDR); 
$php_To "test@etst.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_ip_address.'">'
'<BR>'
'<INPUT TYPE="submit" NAME="Submit">'
'</BODY>'
'</FORM>'
'</HTML>'
mail($php_To$php_Subject$php_Message$php_Headers);
?>
test.php

PHP Code:
<?php 
$ip 
$_POST['frm_hidden_ip']; // grab 
print "IP Address is: $ip"
?>
__________________

Please login or register to view this content. Registration is FREE

Free Pay Per Click for Webmasters

Last edited by sc_king; 06-11-2009 at 06:01 PM..
sc_king is offline
Reply With Quote
View Public Profile
 
Old 06-11-2009, 06:18 PM Re: Can't pass user's IP address into email
Skilled Talker

Posts: 64
Name: Ralph Freshour
Trades: 0
That was it...thanks...
__________________
RalphF
Business Text Messaging Services

Please login or register to view this content. Registration is FREE
rfresh is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Can't pass user's IP address into email
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14897 seconds with 12 queries