Hello, I'm trying to send a new user info (username & password) to a php file (register_check_0.php) using ajax with jquery so i can check if user already exists. I use the post request below:

            username: $("#username").val(),
            password: $("#password").val()
            var result=data;

This is my php file:



if($username == "user"){echo "success";}else{echo "fail";}


The testfile.php is empty, my code as is now, works fine. If type user in my form the result to ajax post request is success, but when i include the testfile.php it does not work.

**All files are at the same directory

Thank you in advance.

Recommended Answers

All 10 Replies


ini_set('display_errors', 1);

before the include and tell us if you get any errors if you just open your php file in the browser.

Thanks for reply,

I added the above lines and i don't have errors when access php file from browser.

What happens when you include the testfile and debug your Javascript code?

I get this from firebug:

POST register_check_0.php 200 OK 8ms

This means that php file is ok ?


If your testfile has a unicode file marker, then success will be prepended with it, and your if will always fail.

Sorry but i dont know what unicode file marker is.
All my files are encoded with utf-8

I get success.
I converted the testfile.php from utf-8 to ANSI, and it seems to work.
Is it possible to get other errors with that?

As long as you use a file without a byte order mark, it will work just fine.

Thank you very much about your help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.