Small Search issue - works after click button 2nd time

Discussion in 'PHP' started by nates, May 24, 2009.

  1. #1
    I am having a issue with a search box. When I try to input a city name an click the search button a strange thing happens.

    I place a city name: Dallas

    Click search button...NO results show - then I click the search button again and the results for Dallas appear.

    Now I put in Houston

    Click search button...NO results show - then I click the search button again and the results for Houston appear.

    --------Search box code----------
    <form action="<?php echo $subcat_url .'?_action='. $_GET['_action'] .'&current_page=1&location=' .$_GET['city'].'%2C+'. $statename;?>&mi=25" method="get">
    <input type="hidden" name="_action" value="getJobs">
    <input type="hidden" name="cityid" value="<?php echo $xcityid; ?>">
    <input type="hidden" name="lang" value="<?php echo $xlang; ?>">
    <input type="hidden" name="location" value="<?php echo $_GET['city'].'%2C+'. $statename; ?>">
    <input type="hidden" name="jobtype" value="<?php echo $_GET['search']; ?>">
    <input name="search" type="text" size="<?php echo $searchbox_on_top?35:25; ?>" value="<?php echo $_GET['search']; ?>">

    ----------

    But this link works for current term in search box:
    <a href="<?php echo $subcat_url .'?_action='. $_GET['_action'] .'&current_page=1&location=' .$_GET['city'].'%2C+'. $xstatename; ?>">here</a>

    Thanks for any feedback.

    Nate
     
    nates, May 24, 2009 IP
  2. creativeGenius

    creativeGenius Well-Known Member

    Messages:
    273
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    120
    #2
    the error seems odd so i'm assuming your logic flow had some sort of glitch, i only scanned what you posted but the one thing the jumps out is the way you specify the form action, looks like you're stuffing so much variable in there
     
    creativeGenius, May 24, 2009 IP
  3. felluahill

    felluahill Peon

    Messages:
    31
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Try changing the request to a POST request instead of a GET:

    <form action="<?php echo $subcat_url .'?_action='. $_GET['_action'] .'&current_page=1&location=' .$_GET['city'].'%2C+'. $statename;?>&mi=25" method="POST">
    Code (markup):
     
    felluahill, May 25, 2009 IP
  4. nates

    nates Peon

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks for the suggestions...Changed it to post but no luck.

    The weird part is that this link works so it seems to be pulling the correct info.
    <a href="<?php echo $subcat_url .'?_action='. $_GET['_action'] .'&current_page=1&location=' .$_GET['city'].'%2C+'. $xstatename; ?>">here</a>
     
    nates, May 25, 2009 IP