Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8737981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:38:34+00:00 2026-06-13T10:38:34+00:00

On my website I have a dropdown of counties… <form method=post action=/people.php > <select

  • 0

On my website I have a dropdown of counties…

<form method="post" action="/people.php" >
            <select name="county" onchange="this.form.submit()" >
                <option>--Select a County--</option>
                <option value="Avon">Avon</option>
                <option value="Bedfordshire">Bedfordshire</option>
                <option value="Berkshire">Berkshire</option>
            </select>
</form>

I then have my query on my people page…

$county = $_POST['county'];

$sth = $conn->prepare("SELECT * FROM directory WHERE user_active != '' AND County = :county");
$sth->execute(array(':county' => $county));

I want to use URL rewrites to include the county in my url, so when you go to the page after selecting a county it doesnt display like

'www.mysite.com/people.php'

but shows as

'www.mysite.com/people-in-avon'

Im still very much a newbie at PHP but, if I want to do this, will I need to use GET method, and post my data to a php page, that then redirects to people.php? Is it bad practice in PHP to have the queries on page?

I hope this makes sense?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:38:35+00:00Added an answer on June 13, 2026 at 10:38 am

    You first need to use an .htaccess with some basic redirections to be able to use people-in-[country] URLs.

    RewriteEngine on
    RewriteRule ^people-in-(.*) /people.php?county=$1 [L]
    

    In your people.php :

    <?php
    
    // you county is set in GET via the .htaccess
    $county = $_GET['county'];
    
    // database query
    $sth = $conn->prepare("SELECT * FROM directory WHERE user_active != '' AND County = :county");
    $sth->execute(array(':county' => $county));
    
    ?>
    

    To create the URL, you should replace special characters, accents, space…
    But if your counties are in one word, without special characters, you could just do :

    <?php 
    
    // to redirect
    $county = $_POST['county'];
    $url = '/people-in-' . $county;
    // redirect
    header('Location:' . $url);
    

    To retrieve by ID your county, you could do something like that (pseudo code):

    RewriteEngine on
    RewriteRule ^people-in-.*-([0-9]+) /people.php?county_id=$1 [L]
    

    To show the county :

    // you county_id is set in GET via the .htaccess
    $county_id = $_GET['county_id'];
    

    To route to the county :

    // to redirect
    $county_id = $_POST['county_id'];
    
    // fetch the county by id
    // BASIC string cleaning
    $county = str_replace(' ', '-', $county);
    
    $url = '/people-in-' . $county . '-' . $county_id;
    
    // redirect
    header('Location:' . $url);
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form on a website that has a dropdown box and instead
I have a dropdown menu on a website that works perfectly on all browsers
I have a website on with MVC, which has a dropdown in the masterpage.
I have website based on Umbraco 5. I have installed contact form plugin (http://cultivjupitercontact.codeplex.com/).
I am creating a dropdown menu on my website and have more or less
I have implemented a dropdown menu into a website, here: http://www.gardensandhomesdirect.co.uk/ However, The dropdowns
On my website I have several input fields in a form. I want the
I'm creating a registration form on my school project website. I have given a
I am on a mac running firefox. I have a website and the select
i have a Problem with my Website.. I want to make a dropdown-item smaller.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.