Use php to grab the ip address

I have a client who wants to use a standard php comment form to enter the ip address of the user.

I found a code snippet - $ip = $_SERVER ['HTTP_CLIENT_IP'];   but I can't make it work.

Can you see what's wrong with my code (I'm not very experienced with php)?  Or point me in the right direction?

Here is the code:

<? PHP

$mailto = ' [email protected] ' ;

$subject = 'empathy Design request form ";

$formurl = " " http://www.empathydesign.co.UK/contactus.shtml " ;

$errorurl = " " http://www.empathydesign.co.UK/error.shtml " ;

$thankyouurl = " " http://www.empathydesign.co.UK/thankyou.shtml " ;

$email_is_required = 1;

$name_is_required = 1;

$company_is_required = 0;

$comments_is_required = 1;

$uself = 0;

$use_envsender = 0;

$use_sendmailfrom = 0;

$use_webmaster_email_for_from = 0;

$use_utf8 = 1;

$my_recaptcha_private_key = ";

-END OF CONFIGURABLE SECTION-

$headersep = (! isset ($uself) |) ($uself == 0)) ? "\r\n" : "\n" ;

$content_type = (! isset ($use_utf8) |) ($use_utf8 == 0)) ? ' Content-Type: text/plain; charset = "iso-8859-1" ":" Content-Type: text/plain; charset = "utf-8" ';

If (! isset ($use_envsender)) {$use_envsender = 0 ;}

If (isset ($use_sendmailfrom) & & $use_sendmailfrom) {}

ini_set ("sendmail_from", $mailto);

}

$envsender = "-f$ mailto;

$fullname = (isset($_POST['fullname']))? $_POST ['fullname']: $_POST ['name'];

$email = $_POST ['email'];

$company = $_POST ['company'];

$comments = $_POST ['comment'];

$http_referrer = getenv ('HTTP_REFERER');

$ip = $_SERVER ['HTTP_CLIENT_IP'];

If (! isset($_POST['email'])) {}

Header ("Location: $formurl");

"exit";

}

If (($email_is_required & & (($email) empty |! preg_match ('/ @/ ', $email))) |) ($name_is_required & & empty ($fullname)). (($comments_is_required & & empty ($comments))) {

Header ("Location: $errorurl");

"exit";

}

If (preg_match ("/ [\r\n]/ ', $fullname): preg_match (" / [\r\n]/ ', $email)) {}

Header ("Location: $errorurl");

"exit";

}

If (strlen ($my_recaptcha_private_key)) {}

require_once ('recaptchalib.php');

$resp = recaptcha_check_answer ($my_recaptcha_private_key, $_SERVER ['REMOTE_ADDR'], $_POST ["recaptcha_challenge_field"], $_POST ["recaptcha_response_field"]);

If (! $resp-> is_valid) {}

Header ("Location: $errorurl");

"exit";

}

}

If (empty ($email)) {}

$email = $mailto;

}

$fromemail = (! isset ($use_webmaster_email_for_from) |) ($use_webmaster_email_for_from == 0)) ? $email: $mailto;

If (function_exists ('get_magic_quotes_gpc') & & get_magic_quotes_gpc()) {}

$comments = stripslashes ($comments);

}

$messageproper =

"This message has been sent: \n".

"$http_referrer\n".

"------------------------------------------------------------\n" .

"Name of sender: $fullname\n.

"Company of sender: $company\n".

"The email of sender: $email\n.

"IP address of sender: $ip\n\n.

"------------------------- COMMENTS -------------------------\n\n" .

$comments.

"\n\n------------------------------------------------------------\n" ;

$headers =

"" From: \"$fullname\" < $fromemail > ". $headersep. "" Reply-To: \"$fullname\" < $email > ". $headersep.

$headersep. "MIME-Version: 1.0 '." $headersep. $content_type;

If {($use_envsender)

mail ($mailto $subject, $messageproper, $headers, $envsender);

}

else {}

mail ($mailto $subject, $messageproper, $headers);

}

Header ("Location: $thankyouurl");

"exit";

? >

I've never heard of this variable.  It should be $_SERVER ['REMOTE_ADDR'].

Tags: Dreamweaver

Similar Questions

  • How to insert image from mysql into the table using php and create the checkbox in the table?

    How can I insert image from mysql into the table using php and create the checkbox for each data as a vote? Here is my code...

    WELCOME

    connect_error) {die ("connection failed:".)} $conn-> connect_error); } $sql = "SELECT no, Calon, ID, of course, the Image OF THE candidates." $result = $conn-> Query; If ($resultat-> num_rows > 0) {echo ' '; export data of each line while ($row = $result-> fetch_assoc()) {"echo"}}
    NO Candidate INFO Vote
    " . $row ["no"]. "-" . $row ["Calon"]. "
    -" . $row ['ID']. "
    -" . $row ['class']. "
    "; } ECHO ' ' ;} else {echo '0 results' ;} $conn-> close();?} >

    hope someone can help me because I am a newbie in this program... need to finish this project... Thank you.

    If you have saved the file name in the database, it's pretty simple.

    echo '' . $row['description'] . '';
    

    Is the same for the box:

    echo '';
    

    If you have saved the image file in the database, it is much more complicated. I recommend you store only the file name in the database.

  • ESX uses network adapter with the mac address that is different than virtual connect reports

    Hi all

    Our ESX environment consists of HP C7000 enclosure, virtual connect 1 gb ethernet with a mixture of BL480c and BL460c. We just bought some new BL460c G7 with NIC NC553i to replace some of the oldest BL480c. We have configured Virtual Connect to assign mac addresses. In vc management consoleI see the addresses assigned to the server, but when I start the server displays a different mac address for nic #2 that vc does. NIC #1 has the same mac address of console management vc and in the server BIOS. When I install ESX also sees the 'wrong' for #2 nic mac address. According to vmware nic #2 has not any network connected to what should be if it was really nic #2 (according to the vc management console).

    When I look at the mac addresses in the BIOS none of the network interface card have the mac address assigned by vc. VC firmware is 3.01. I have attached the photos I see information in the management of VC and BIOS console. Someone at - it for clues to what is happening and how can I solve it? Thanks in advance.

    Kind regards

    GB

    Please refer to:

    http://KB.VMware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalID=1001167

    Note:   The ESX host uses following addresses starting with 00:50:56 (as opposed to the address embedded in the interface itself).

    To determine the MAC address of the interface Board of the ESX host, run the command:
    # ifconfig | grep-i hw
    The output looks like:
    vswif0 Link encap HWaddr 00:50:56:41:5 A: 59
    The MAC address is in the first line after HWaddr.  In this example, the MAC address is 00:50:56:41:5 has: 59.

    Note:   The ESX host uses following addresses starting with 00:50:56 (as opposed to the address embedded in the interface itself).

    You can also review the output information and the esxcfg-NICS - l order MAC addresses.
  • Can I use PHP scripts in the sites of Muse?

    Anyway to call PHP scripts on a Ste of Muse.  I want to install a small ad on a site script.

    You can try and test, useful links:

    http://www.thejohnnyoshow.com/coding-corner.html

    http://www.phpmuse.com/HOWTO.html

    Thank you

    Sanjit

  • I do not use a proxy server to connect to internet, but Firefox is automatically configured to use the loopback address.

    I have a direct connection to the internet and that you do not use a proxy server. Every few weeks, Firefox will automatically reset itself to be configured to use a proxy to the loopback address (127.0.0.1). Manually change to 'No proxy' works, but I have to do so every time I open the browser or even a new tab. The only solution I can find is to create a new profile that gives me a new, clean install of FF, but then I lose all my Add-ons. This has happened several times now and it's extremely frustrating. I have scanned for malware, but have not found any problems.

    Hello rjlasser, first of all please make sure that none of your extensions is the origin of the problem (some circumvention of censorship of youtube addons do also use proxies for example).

    Otherwise please see How to fix the preferences that will not save for common solutions.

  • How to save the custom of the user using PHP field?

    Hello!

    I am looking for a way to share specific data to the user between connected users. For example, all participants must know each other IDs (our own system IDs, no ACC).

    Custom user fields seems the best solution for this, but I can't find a way to save one using PHP, while creating the room.

    How to save the custom of the user using PHP field? Or maybe there's best solution to do such things?

    Had, just add the new node to the UserManager collection.

    const USER_MANAGER_COLLECTION = 'UserManager';
    static private $USER_MANAGER_CUSTOM_FIELD_CONFIGURATION = array(
       'accessModel'=>self::ROLE_VIEWER,
       'publishModel'=>self::ROLE_VIEWER,
       'persistItems'=>true,
       'modifyAnyItem'=>false,
       'userDependentItems'=>true,
       'sessionDependentItems'=>false,
       'itemStorageScheme'=>self::STORAGE_SCHEME_MANUAL,
       'allowPrivateMessages'=>true,
       'lazySubscription'=>false,
       'p2pDataMessaging'=>false
     );
     const USER_INVITE_ID_CUSTOM_FIELD = 'inviteId';
     static private function createUserManagerCustomFields($room){
       $account = self::init();
       $collection = self::USER_MANAGER_COLLECTION;
       $account->subscribeCollection($room, $collection);
       $account->createNode($room, $collection, self::USER_INVITE_ID_CUSTOM_FIELD, self::$USER_MANAGER_CUSTOM_FIELD_CONFIGURATION);
     }
    
  • Getting the IP address of the client

    Anyone know how to get the client IP address?

    Under the authentication/stats/logging system, we would like to have all of the IP addresses that are stored in the database, but I can't for the life of me how to get (looking for the documentation returned nothing flash and google keeps raising people who seek intellectual property in flash and then says to use PHP/CF to the to do...).

    Certainly, there must be a way to get the ip address.

    Thank you.

    Found in Client.ip

  • How to add the delivery address to a profile?

    Hello

    How to add a delivery address to a profile? Can we add using ProfileFormHandler shipping address? I googled a lot but has no solutions. Also the ATG docs aren't useful. But I see a Web Service Guide to add Oracle ATG Commerce Web address - add an address for a profile of customer... Is this the only way?

    Please help me has add a delivery address to a profile?

    Thank you.

    Hi Ronald,.

    Yes, you can use ProfileFormHandler to add the delivery address in the profile.

    For example, in your CustomProfileFormHandler, you can write a method handleNewAddress which

    * You can create a new delivery address using the inputs is entered in a map [it's a card that stores the value of properties of addresses] frontend page.

    * Then, create an object of the address of the value entered by the user.

    * Then to this new address create an entry in the secondaryAddress on profile plan. Set this new identity as the newAddressId, so it can be picked up on the success page.

    * Check that Profile.ShippingAddress is set to null, if it is, add the new address as default delivery address and copy the default home delivery address [If you want to see the first address as the default address].

    * Empty the card.

    Hope it helps.

    Kind regards

    Prateek G

  • Form open through the IP address instead of the server name in the URL!

    Hi all

    We have forms 11 GR 2 64-bit with the JDK 7 9 on server update and updating JRE 7 25 on PC clients.

    I m facing problem in one of my customer's PC. Please note that follows;

    http://svr:9001/forms/frmservlet? form = new, it does not open my form and displays the error.

    http://192.0.0.1:9001/forms/frmservlet? form = new, it allows to open my screen successfully without any errors.

    that is when we enter the server name in the URL, it does not open my form. But when we enter the IP address of the server, its ok.

    It must use the name of the server, exactly as it is defined in the global variable, which is used to open reports. Thus, if we use

    IP in the URL address, it opens to all reports.

    This problem occurs in one of my PC, other customer client PC is OK.

    Help please!

    Thanks/regards,

    Dass.

    Hello

    as explained by Sham, but among the 'hosts' file on the local pc not the server and also the other way around

    That is to say

    SRV 192.0.0.1

    It is the local file that will be used to translate the name "srv" in the IP address of the "192.0.0.1' for the network software from the local pc power"watching"at this address.

    So when you ask "srv" the "hosts" file can be inspected and the IP address of the returned '192.0.0.1' as translation

    Stem

  • Use PHP Variables between pages: Session, URL, or Get

    Hello

    For our association, I developed a registration page.  Registration pages insert a record into a mysql database, using php.  After the user submits the form (by using $post), I want to be redirected to the confirmation page where a mysql database query is executed to retrieve the record, the Member has been added.

    To pass the variable, I have developed the following pages using a session variable.

    Registration page: http://www.aosweb.org/member_dues.php

    Confirmation page: http://www.aosweb.org/member_view.php

    Although I asked recently changes to the code, it worked at the same time.  The forum was helpful to get the information I needed.  At this point, the redirect, and the passage of the session variable does not work.  It seems that the available on the page member_view session variable is of the last inserted record.  Thus, the query that is run on member_view returns no result.

    I checked some of the forum posts, such as:

    -php url parameters

    -How to pass parameters of form to confirm page...

    -php help registration page!

    My questions outstanding are as follows:

    1 have I placed the order to set the $_session ('sv_mem_num') in the right place.

    2 should I consider another method such as a URL or by using the Get method parameter.

    Thank you.

    George

    $insertGoTo = ' member_confirm.php? mark = ". $_POST ['Member_Num']. » « ;"

    If (isset {}
    $insertGoTo. = (strpos ($insertGoTo, '?'))? "&" : "?";
    $insertGoTo. = $_SERVER ['QUERY_STRING'];
    }

    What is happening is that the Dreamweaver code is looking for an existing query string and add it. The problem is that you put a query string in your redirect page, which translates as the ampersand is added at the end. That's how I want to change it:

    // set the redirect to the target page without a query string
    // then let Dreamweaver check for an existing query string
    $insertGoTo = "member_confirm.php;
     if (isset($_SERVER['QUERY_STRING'])) {
     $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
     $insertGoTo .= $_SERVER['QUERY_STRING'];
     }
    
    // if a query string has been added, add the memid at the end
    // otherwise, create a query string to add memid
    if (strpos($insertGoTo, '?')) {
     $insertGoTo .= '&memid=' . $_POST['Member_Num'];
    } else {
     $insertGoTo .= '?memid=' . $_POST['Member_Num'];
    }
    
  • How can I get FF to work with organizing Mod (for the mods used with ARE: Skyrim)? I get an error message that it cannot understand the given address.

    I am a big fan of the Elder Scrolls and uses the new 2.2.9 STEP Setup. They went to the organizer of the Mod (MO) and I can't seem to get my FF working with the mod download things part. I click on the icon "Earth", that takes me immediately to the page file Nexus Mod, but when I choose a file to download after clicking on "Download Manager" I get this error message:
    The address was not included
    Firefox doesn't know how to open this address, because one of the following protocols (nxm) is not associated with any program or is not allowed in this context.
    You may need to install additional software to open this address.

    The address when clicking "Download Manager" begins with nxm://Skyrim/mods/ the address is such because trying to download with the Manager.

    Any help will be greatly appreciated! I pulled out my hair for the last few hours trying to find a solution. I disabled Adblock, other popups blockers and activated the main address in my exception rules. It simply doesn't get it. Ugh!

    Thank you in advance!

    In order to use nxm: / / links, Nexus Mod Manager must be installed and associated with the Protocol nxm .

    Problems with this program to third parties, please see the support forum:

  • Help submitting the form using php

    Using DW CS5.5, I created a simple contact form 12 field. Rather than using a cgi script to send form data, I prefer to use php.  Can someone provide me with a source for simple instructions on how to do it?  I searched past discussion forums, but can't find anything that will guide me in the specific steps.  The form is already installed on my page, but now I don't know what to do next to make functional, so it will send to my address e-mail, form data when the user clicks the submit button.  I checked online also, but to find the instructions more geared towards those who have more experience or knowledge than me in this kind of things.  Creation of shapes on the page is easy, and I understand the big picture regarding how work of forms, and what happens in the background, but it is impossible to find out what either written in simple language that will tell me step by step what to do after the creation of the form on the page.

    Thanks for anyone's help.

    Nancy has written a good tutorial Alt-Web Design & Publishing: Contact form sensitive with 3.2 Bootstrap and PHP (part 1)

    The PHP part starts Alt-Web Design & Publishing: sensitive Contact with 3.2 Bootstrap and PHP (part 2) form , but it does not hurt to start from the beginning

  • New version of Thunderbird grabs all Mac addresses Mail instead of simply treat associated with the email for Thunderbird account. Why?

    Old version not shown contacts associated with the email address associated with Thunderbird. New version captures all THE addresses listed in my Mac Mail address book program. Is a huge list if I'm looking for an address or a specific person. A real pain! Any way to stop this?

    Problem solved. Just say Thunderbird is not to use this address book. All back to normal now...

  • My GMail Goggle address is used as the return address

    I have set up my email accounts with email response answer such as email for the account, everything was fine and was sent the correct answer to the address until I have configure the SMTP Protocol to use my Goggle GMail because it is a laptop, and I move. Given that I've implemented using GMail as my outgoing server Thunderbird using my GMail username as my answer by email to the address in all my email accounts. I've looked everywhere, and is the only place in my GMail address as my user name in the SMTP server settings. How can I stop using this GMail address in my accounts and serve as a response to the installation address?

    When you configure the gmail smtp service, you declare an e-mail address for use with. Regardless of what "from:" address you use, gmail silently replace by associated, gmail address as you worked on yourself.

    If you use gmail smtp, you must 'connect' your other email addresses for the incoming (pop/imap) account with gmail. Register a non-gmail addresses on your settings page of gmail on the gmail website.

  • Firefox won't let me copy the web address of the bar using the context menu with the second mouse button or trackpad to address

    Hello!

    I am writing to report a problem I have with the new patch v35 and v35.0.1 Firefox address bar

    With the new version 35 of Firefox on Mac OSX Yosemite, clicking with the right mouse button in the address bar to copy the web address, a context menu DO NOT allowed to copy the link, he shaded in grey, inactive... you click on an other browser zone before returning to click a second time and be able to copy the link in the context menu

    I mean, with the first right click on the menu bar that appears to address do not allow me to copy the link directly, you must click another area and then click again with the right mouse button in the address bar to copy the Internet address (happens to all pages)

    I tried to open Firefox plugins and completed inactive and reset Firefox on first use (as the first installation) and the problem is here again... The problem with or without add-ins and plugins is here

    What happens before and then when I format my computer

    Here I put a screenshot that explains the problem better than my words
    http://i.imgur.com/QxKd8P1.gif

    I hope you can help me

    Hello

    I want to just inform you that with the new version 36 of Firefox, this problem has been corrected in my browser
    Now I can access the copy option in the context menu directly in the address bar
    Thanks for the replies

Maybe you are looking for

  • SXS memory card does not work with El Capitan

    Does anyone know of a new driver for SXS with El Capitan?

  • my itunes library sharing

    Hi, I wonder if someone can help me? I want to put songs from my itunes library on my girlfriends without sync phone or mess up a phone? She has a lot of albums, but we only have a laptop and it is set up for my phone, is there a way to do this? Than

  • DV6 3152sl: disk hard dv6

    Hello my hp dv6 3152sl not find the hard drive on startup (error 3F0).  But if I start a linux installation, which detects the drive and I can install the operating system. at the end of the installation when I reboot, the bios can not find the disc

  • New printer for 80 lb cover Stock (greeting cards)

    Hi all... Well, my Canon Pixma iP6700D has bit the dust.  What printer model Canon printing color on 80 lb. cover stock (greeting cards) would you recommend?  I'm stumped... as it is difficult to find a printer/recharge now...  Thanks a lot for any h

  • Aspire touchpad e11 problems

    I bought a pair of laptops E3-112-C10V for my partner and myself, its touchpad is intermittent and so I'll check if the suggested addition bios change contributes to its situaation. On my laptop touchpad disappeared, it is more listed in the settings