The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Hiding GET Variables From The URL - Or Alternative?

Hey guys,

I have a dilemma: I have a search form, and I'd like the search query to be passed to the URL (for SEO purposes), so GET is essential. I'm using the Google Adsense For Search, so I'd rather not change the essential form code. I only want the search query string to be in the url (q=search+here), but there are a bunch of hidden values for google, such as the partner ID and other values.

How do I hide all those values and just show the search term? I need the search query in the URL, so method "POST" can't be used.

Would you kindly instruct me how to use session variables to pass the variables? I can't seem to figure it out. I tried defining the session values on the search page, and then defined the equivalent GET values as the Session values on the next page. What's wrong with that?

Cancel the hidden form fields, and create them as session variables. Then, in the script that receives the form values, you can address the session variables. Don't forget to declare session_start() on the first line in both pages

form page:

PHP Code:

<?php
// first line: session start
session_start();

// everything else you need to do (like getting the hidden values from your DB or whatever) goes here

Thanks for the reply again. I tried doing what you said, but for some reason the Google search isn't working, which is strange; the original Google search code used Post, but even when I changed that to GET, the search still worked. So now, I replaced the hidden values with session variables, and set the variables on the next page like this:

For some reason, Google isn't registering those hidden variables. Any idea why that is? It might be because Google isn't using PHP to work with the code, so it has to be in the URL or in the POST data. Is there a way to maybe include the search query in the URL, but still use POST? Or maybe, to use the search query as GET and the rest as POST? Or maybe since google's code is written in Javascript, somehow to let JS know that these variables exist?

Thanks for the reply again. I tried doing what you said, but for some reason the Google search isn't working, which is strange; the original Google search code used Post, but even when I changed that to GET, the search still worked.

You know, I completely missed the not so small detail that you're talking about google adsense for search
Session variables are of no use, because google can't read them. Sorry that I've made you loose so much of your time.

I don't know about JS. Maybe someone else. Maybe on the JS forum.

But why do you think using $_GET instead of $_POST to send the search to google will improve SEO? Whose SEO? Yours? Google's? SEO for what page?

You know, I completely missed the not so small detail that you're talking about google adsense for search
Session variables are of no use, because google can't read them. Sorry that I've made you loose so much of your time.

I don't know about JS. Maybe someone else. Maybe on the JS forum.

But why do you think using $_GET instead of $_POST to send the search to google will improve SEO? Whose SEO? Yours? Google's? SEO for what page?

No problem Thanks for your time anyway.

Google for Search allows you to put the custom search results directly into your own page. This means that I can now directly link to a search result on my own site and optimize it for search engines. So, I can link to a custom search with the URL domain.com/search?q=search+query+here, but I can't exactly do it if there's too much trash in the URL