Jump to content

!!HELP!! Trouble with Ajax <INPUT> function!


POGRAN

Recommended Posts

Hi there, guys!
I have a search page on my web site that gets the information about user by his username from MySQL database.
It has two input fields: username and full name
A visitor is typing in the username field his username, clicks on "Get Name" link and in the second field he sees his name.

I know that it is possible to realize it in Ajax. I wrote already some code, you can see it's source here:
[url=http://www.pogran.nm.ru/xajax.txt]http://www.pogran.nm.ru/xajax.txt[/url]
(it uses xAjax class)

The only problem is that it doesn't get the full name correctly, it gets the fullname of user whose username = "". That means that the function check() doesn't see the $username (field's data)

What is wrong with the script can you help me please guys!?
Thanks in advance!
Link to comment
https://forums.phpfreaks.com/topic/26181-help-trouble-with-ajax-function/
Share on other sites

function check([color=red]$asd[/color])  ?

Try:
[code]
function check($username)  {
                $result = "SELECT * FROM users WHERE username='$username'";
                $result_sql = mysql_query ($result);
                $myrow = mysql_fetch_array($result_sql);
                $name = $myrow["name"];

  $objResponse = new xajaxResponse();
  $objResponse->addAssign('full_name', 'value', $name);
  return $objResponse->getXML();;
  }
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.