SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Zealot thetzfreak's Avatar
    Join Date
    Aug 2004
    Location
    United States
    Posts
    154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.

    Any suggestions appreciated.

    Thanks.

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,495
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    If they're not form values that must be inserted by the user, you can store them as session variables or cookies. Or retrieve them from your database every time.

  3. #3
    SitePoint Zealot thetzfreak's Avatar
    Join Date
    Aug 2004
    Location
    United States
    Posts
    154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply.

    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?

    Thanks.

  4. #4
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,495
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    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

      // set the session variables with the hidden values
      
    $_SESSION['partnerID'] = $partnerID;
      ...
    ?>
    <form action="secondpage.php" method="get">
      <label for="field1">Field1</label>
      <input type="text" name="field1" />
      <input type="submit" name="submit" value="Submit" />
    </form>
    secondpage.php:
    PHP Code:
    <?php
      
    // first line: session start
      
    session_start();
      
      
    // get the session variables with the hidden values
      
    $partnerID $_SESSION['partnerID'];
      ...

      
    // everything else you need to do goes here

    ?>

  5. #5
    SitePoint Zealot thetzfreak's Avatar
    Join Date
    Aug 2004
    Location
    United States
    Posts
    154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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:

    PHP Code:
    $_GET['val1'] = $_SESSION['val1'];
    $_GET['val2'] = $_SESSION['val2'];
    $_GET['val3'] = $_SESSION['val3']; 
    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?

    Is that possible?

  6. #6
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,495
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by thetzfreak View Post
    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?

  7. #7
    SitePoint Zealot thetzfreak's Avatar
    Join Date
    Aug 2004
    Location
    United States
    Posts
    154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by guido2004 View Post
    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

  8. #8
    SitePoint Zealot thetzfreak's Avatar
    Join Date
    Aug 2004
    Location
    United States
    Posts
    154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can anyone help me out with this please?

    Thanks.

  9. #9
    SitePoint Zealot thetzfreak's Avatar
    Join Date
    Aug 2004
    Location
    United States
    Posts
    154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Once more, can anyone help with this problem?

  10. #10
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What you're asking is impossible by definition. You can't show something and not show something.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •