Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 2nd, 2009, 01:01 PM
Authorized User
 
Join Date: Jul 2008
Posts: 24
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via MSN to ramone_johnny
Question Simple PHP question - Obtaining the users IP address

Hi guys,
Im actually an ASP programmer (dont hate me) and I need some help with this snippet of code.

What I want to do is to get the users IP address and send it in the email body, or as part of the email message.

Im totally lost with this - no PHP programming knowledge at all!

Code:
<?php
// Your email address
$email = [email protected];
// The subject
$subject = "Attempted Purchase : $17";
// The message
$message = "A visitor has attempted to buy at $17";
mail($email, $subject, $message, "From: $email");
// redirect back to url visitor came from
header("Location: http://7.xxxxxx.pay.clickbank.net");
?>
I know to capture the users IP i have to use something like $_SERVER['REMOTE_ADDR'];

But where do I put it?

John
__________________
Works Media - Online Marketing & SEO
 
Old April 2nd, 2009, 01:24 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I am not a PHP guy but this article should be able to help you: http://www.plus2net.com/php_tutorial/php_ip.php

And you will want to concat, I am assuming, the IP Address to your message variable. Check this out: http://www.php-mysql-tutorial.com/wi...gs-in-php.aspx
hth.
-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
 
Old April 2nd, 2009, 02:11 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Please don't randomly spam threads. If you want to contribute something to the conversation that is wonderful but comments like that are neither helpful or funny. Thanks.

-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
 
Old April 2nd, 2009, 02:25 PM
Authorized User
 
Join Date: Jul 2008
Posts: 24
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via MSN to ramone_johnny
Default

Can someone possibly just paste up the code that I need ??
__________________
Works Media - Online Marketing & SEO
 
Old April 2nd, 2009, 02:35 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Now come on, stop being lazy. In the time it took you to write your post you could tested the code two different ways and got your desired result. I gave you everything you need.

Something like this:

$message = "A visitor has attempted to buy at $17" . $_SERVER['REMOTE_ADDR'];
or
$ip = $_SERVER['REMOTE_ADDR'];
$message = 'A visitor has attempted to buy at $17. IP = $ip';

This is a trivial problem, i don't see why you can't put forth a little effort to try and solve it.

-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
The Following User Says Thank You to dparsons For This Useful Post:
ramone_johnny (April 2nd, 2009)
 
Old April 2nd, 2009, 02:42 PM
Authorized User
 
Join Date: Jul 2008
Posts: 24
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via MSN to ramone_johnny
Default

Sorry Doug,
Its 4:41am here - my eyes are hanging out of my head.

Thanks for your help - Im off to bed mate.

John
__________________
Works Media - Online Marketing & SEO
 
Old May 7th, 2009, 02:22 PM
Authorized User
 
Join Date: Nov 2008
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Cool Try this.

I think this might help you.


Code:
$message="A user from".$_SERVER['REMOTE_ADDR']."has attempted to buy at$17";





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help me i must Get IP Address pla_2 C# 2005 2 October 12th, 2006 07:51 AM
IP Address sumanghosh Classic ASP Basics 1 April 7th, 2006 11:24 AM
How to get IP address shankhan Classic ASP Databases 6 March 10th, 2005 04:18 PM
simple apache and php question nulogix PHP How-To 1 July 19th, 2004 09:06 PM
Retreiving IP address & gateway address sjangit VBScript 0 February 3rd, 2004 02:02 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.