The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.
I would like to copy a url after entering a search term.
I have a search text field with a search button that searches an outside webpage. For example, my search text field and button is on my page but when you type in a term it goes to the google page. I want to extract that url using php. Is there anyway to do that?
Also, when someone searches using the search field on my page, instead of going to an external page (i.e. google), I want it embeded on my site instead. So when you search "cat" in my page, it will return the results on my page instead of going out to google's external page. I hope that makes sense.
Yes and no. The description of the problem is still a bit blurry.
PHP code is executed before the page is drawn and sent to the user. So, if you're trying to capture user interaction with an element on the page after the page is drawn, no, php cannot do that. Basically the purpose of php is to allow a user to dynamically generate output content from sql statements.
What you are trying to do is a fairly common problem... you want to fit input from another source within your own portal. Generally there are two ways of doing this:
1. Rewriting the user's page when you write it out so that their form action sends to you, and then you send their form data on, get the response back, reformat it, and return it to the user. This works ok in an unsecured setting so long as you're confident you won't get sued. Since this is server side, php IS capable of doing this, but as solutions go this is remarkably clunky and if I tried to do this at work I wouldn't have a job for very long.
2. Using AJAX to intercept the data on the client side and reformat it, making it seem like the data is originating from you but really being produced by transformations on the client side. This is easiER to do with data that's not already formatted for rendering (like raw xml data as opposed to an output html page). Like data reached by a web service for example.
Google's search API enables you to use google as a web service, so that you can put data from their site into your interface with minimal pain. They have some examples such as the blogger search gadget which is designed for inline display of search results. But this is ajax code, not php, so it runs client side.
YPHP code is executed before the page is drawn and sent to the user. So, if you're trying to capture user interaction with an element on the page after the page is drawn, no, php cannot do that. Basically the purpose of php is to allow a user to dynamically generate output content from sql statements.
Sorry, just had to step in here and salmon that for horrible horrible lies.
DoopHQ: The "best" way would be to try and use Gothic's Google API suggestion, as that way you are "playing nice".
Posts
PHP code is executed before the page is drawn and sent to the user. So, if you're trying to capture user interaction with an element on the page after the page is drawn, no, php cannot do that. Basically the purpose of php is to allow a user to dynamically generate output content from sql statements.
What you are trying to do is a fairly common problem... you want to fit input from another source within your own portal. Generally there are two ways of doing this:
1. Rewriting the user's page when you write it out so that their form action sends to you, and then you send their form data on, get the response back, reformat it, and return it to the user. This works ok in an unsecured setting so long as you're confident you won't get sued. Since this is server side, php IS capable of doing this, but as solutions go this is remarkably clunky and if I tried to do this at work I wouldn't have a job for very long.
2. Using AJAX to intercept the data on the client side and reformat it, making it seem like the data is originating from you but really being produced by transformations on the client side. This is easiER to do with data that's not already formatted for rendering (like raw xml data as opposed to an output html page). Like data reached by a web service for example.
Google's search API enables you to use google as a web service, so that you can put data from their site into your interface with minimal pain. They have some examples such as the blogger search gadget which is designed for inline display of search results. But this is ajax code, not php, so it runs client side.
http://code.google.com/apis/ajaxsearch/documentation/
Sorry, just had to step in here and salmon that for horrible horrible lies.
DoopHQ: The "best" way would be to try and use Gothic's Google API suggestion, as that way you are "playing nice".