0

I have simple form:

<form action="/" method="get"> 

<select name="category">
<option value="social">social</option> 
<option value="tech">tech</option> 
</select>

</form>

If I choose tech and submit the form like this, i will get /?category=tech appended in the URL. Is it possible to get the SEO slug submitted instead. For example: /tech

1
  • use htaccess and rewrite urls Commented Oct 25, 2013 at 16:29

2 Answers 2

2

You probably need some javascript on the onsubmit part of the form.

http://jsfiddle.net/qwa54/

Sign up to request clarification or add additional context in comments.

Comments

0

U can tying the below th link. Hi, u will try the .htaccess through the redirect the link
http://www.generateit.net/mod-rewrite/

Based on the slug functions we can crete seo friendly url.

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
       <label>Enter the Text :</label><input type="text" name="name"><br>
    <select name="category">
    <option value="social">social</option> 
    <option value="tech">tech</option> 
    </select><br>
       <input type="submit" name="submit" value="Submit Form"><br>
    </form>

<?php

function seo_friendly_url($string){
    $string = str_replace(array('[\', \']'), '', $string);
    $string = preg_replace('/\[.*\]/U', '', $string);
    $string = preg_replace('/&(amp;)?#?[a-z0-9]+;/i', '-', $string);
    $string = htmlentities($string, ENT_COMPAT, 'utf-8');
    $string = preg_replace('/&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);/i', '\\1', $string );
    $string = preg_replace(array('/[^a-z0-9]/i', '/[-]+/') , '-', $string);
    return strtolower(trim($string, '-'));
}
?>
<?php
if(isset($_POST['submit'])) 
{ 
     $name = $_POST['name'];
     $category = $_POST['category'];
    echo "<b>input value : </b>".$name;echo "<br>";
    $seofriendname = seo_friendly_url($name);
    echo "<b>SEO Function value</b> </br>".$seofriendname;
}
?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.