Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more

Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Web Programming > PHP Development
User Name
Password

Reply
 
LinkBack Thread Tools Display Modes
Old 06-13-2009, 11:12 AM   #1 (permalink)
ramonas001
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]
__________________
aprilaire 4396508
ramonas001 is offline   Reply With Quote
Sponsored Links
Old 07-05-2009, 02:59 PM   #2 (permalink)
user24
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, 03:04 PM   #3 (permalink)
user24
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
Display Modes

Posting Rules

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

Points Per Thread View:
Points Per Thread:
Points Per Reply:



» 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 02:26 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0 RC8
Webmaster Forums