0

I have a html form which method type is post, now i want to append text to my website url in PHP. The text changes dynamically.

current url :

www.example.com/index.php

expected url :

www.example.com/index.php/hotels-in-bangalore 

(or)

www.example.com/index.php?qry=hotels-in-bangalore

I just want to append text, other than that every thing should remain same. Thank you.

1
  • Can you post your HTML form code, so that we can get an idea of what you are trying to do? Commented May 3, 2014 at 13:36

2 Answers 2

1

Im not sure why you try to accomplish, but here are few solutions:

put url in form action:

<form action="index.php?qry=hotels-in-bangalore" method="post">

or you can do it in php

if (!empty($_POST['name']) {//put some logic here
  header("Location: index.php?qry=hotels-in-bangalore");
  exit;
}
Sign up to request clarification or add additional context in comments.

Comments

0

You need to use JavaScript if you want to redirect to correct page after submitting immediately.

So it will be something like this:

<form>
  <input type="text" name="tbSearch" id="tbSearch" />
  <input type="submit" id="submitSearch" value="Submit" />
</form>

<script type="text/javascript">
$("#submitSearch").click(function() {
   window.location.href="index.php?qry=" + encodeURIComponent($("#tbSearch").val());
});
</script>

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.