Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7935597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:58:18+00:00 2026-06-03T21:58:18+00:00

I have an HTML form. When visitor submits form, a javascript method is invoked.

  • 0

I have an HTML form. When visitor submits form, a javascript method is invoked.
This method sends an AJAX request to my server’s php file.
My problem is i need to get the visitor’s ip address. But because of AJAX request calls php file, $_SERVER[‘REMOTE_ADDR’] gives me my server’s address.
How can i get visitor’s ip, in this case?
Thank you

<form onsubmit="sendData(); return false;">
    // some data here
</form>

function sendData(){
    // do some work, get variables
    $.ajax({
        url:"/mypage.php",
        type:"GET",
        data: { name: e },
        success : function(data) {
           // do some work
        },
        error: function (xhr, ajaxOptions, thrownError) {
        }
    })
}

// in mypage.php
public function useData() {
        $name=$_GET["name"];
        $ip = $_SERVER['REMOTE_ADDR'];
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T21:58:20+00:00Added an answer on June 3, 2026 at 9:58 pm

    $_SERVER['REMOTE_ADDR'] will give you the IP address of the client. But since presumably you are using the same machine as server and client you get the same IP which is normal. Once you host your website into a web server and access it remotely from a different machine you will get the address of that remote machine.

    So there’s nothing more you need to do. Your code already works as expected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this html form which calls a php file . The index.html ->
I have this html form echo <form name='delete_article_form.$row['id'].' action='sources/public/article_processor.php' method='POST' >; echo <input name='processor_switcher'
I have a html form with the data by this post method 'form id='form1'
I have the following form that has 2 selects: <form id=form class=form_visitar method=post action=ajax/selects.php>
I have an HTML form that submits to a PHP page which initiates a
I have a HTML form that submits to PHP. There is an onChange event
I have html form with submit button and input='file' control: <form action=/Profile/UploadFile enctype=multipart/form-data method=post
I have a following problem, I have HTML form that uploads a file with
I have a html form for uploading a file, which is as follows: $uploadhtml
I have a html form on DNN website. This form will submit data to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.