tags:

views:

53

answers:

1

Hi There, I am developing an app using twitter API,in which any user can enter his twitter username in textbox and get his followers. On home.php , I am using jquery. on click event of button, I am calling getinfo.php and passing textbox value along with it. This is the case so far.

What I want to do? Right now my url is:

http://www.example.com this redirects to

http://www.example.com/home.php

Now I wish that my URL should also work like this:

http://www.example.com/username

means when user will type sitename and his username he should get his results. As I am trying jquery first time, I am not getting how can I pass value of URL (username in this case) to getinfo.php directly?

or any other solution?

Can you guys help me with this? please ask for any details.

Your help will be greatly appreciated.

Thank you in advance.

Here is a posted code on demand the click event in jquery:

$(document).ready(function(){
   $("#btonsubmit").bind('click', function(){
$.get('/getinfo.php?tnm='+$('#tnm').val(), '', function(data){
                $('#get_data').html(data);
   });
}
)};

// here tnm is name of textbox. and btonsubmit for button

A: 

You can do this like below.

step 1: update your .htaccess file . add one line

ErrorDocument 404 /notfound.php

This will redirect your user to /notfound.php

step 2: on notfound.php, get any how URL that user has called like http://yoursite.com/username

below line might help you to get that URL, not sure...

$url = $_SERVER['HTTP_REFERRER'];
  • extract username from this url.
  • check whether this userName exist? if exist process getInfo.php with that username..

else redirect to notfound.html..

I am not sure as this will work or not?? the main Question is whether you will get URL with $_SERVER['HTTP_REFERRER'];

Maulik Vora
yes not getting url with $_server['HTTP_REFERRER'];
Rishi2686
sorry :(. I have observed that most sites having such username functionality are using frameworks.
Maulik Vora