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

  • Home
  • SEARCH
  • 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 7868213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:55:47+00:00 2026-06-03T00:55:47+00:00

I think I’m doing this wrong for what I want returned with PHP. What

  • 0

I think I’m doing this wrong for what I want returned with PHP. What I’m trying to do is check if the username is paid or not via ajax.

The PHP, which works by itself if I do this:

$username = $_POST['username']; 

     function checkPlayer($player) {
        $mcURL = 'http://www.minecraft.net/haspaid.jsp?user=';
        $auth = file_get_contents($mcURL . $player);

        if (trim($auth) == "true") {
          echo $player. ' is ';
        } else {
          echo $player. ' is ';
        }

        return $auth;
      }

      echo checkPlayer($username);

Does what I want if I change $username value to something static, like $username = "Notch";. But not if I use $_POST['username'], and use the following JS:

$(document).on('keyup', 'input', function(){

        var inputVal = $('input').val();
        $.post('auth.php', inputVal, function(data){
          console.log(input.Val + ' is ' data);
        });
      });

Which should print out in console if I typed in ‘Notch’, true, if something else like ‘fslfjslkfjls’ should be false.
HTML:

<form>
    <input type="text" name="username" value="" class="authcheck">
  </form>

What do I have wrong?

UPDATE: After galchen’s answer, it (kinda) works now (doesn’t give an error)

var inputVal = $('input').val();
        $.post('auth.php', { 'username' : inputVal }, function(data){
            console.log(inputVal + ' is ' + data);
        });

But now everything that inputs returns true, even if it’s not true. How can I fix this?

  • 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-03T00:55:49+00:00Added an answer on June 3, 2026 at 12:55 am

    try:

    $.post('auth.php', { 'username' : inputVal }, function(data){
        console.log(input.Val + ' is ' data);
    });
    

    you need to send the object in the ajax – it’s a dictionary of the request variables

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

Sidebar

Related Questions

I think I have a fairly basic question here. I'm not trying to waste
Think that I have many activities,and all I want is this: I have a
I think this has probably been asked, but after reading a lot, I'm not
think this should be an easy one... I want to get the currently selected
I think most people know how to do this via the GUI (right click
I think this is a simple SQL query problem, but I am just not
Think about doing this: import matplotlib.pyplot as plt plt.plot(x_A,y_A,'g--') plt.plot(x_B,y_B,'r-o') plt.show() How would you
I think everyone knows this site http://pinterest.com/ and I don't want to create site
I think I've almost got it, but not there quite... I want to select
Think I have an activity with some layouts, I want to know is it

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.