0

I have a website (www.website.com) and on the homepage is a form, where the user set up a city. After sending the form, I am trying to have the following URL address:

www.website.com/city-name

But I am lost a bit here, because I am not sure, how to set up the form (GET or POST is better for this need?), and .htaccess.

Could anyone help with this? Thank you

2
  • Do you need this URL to request this page direct over the URL? Commented Jan 5, 2013 at 16:53
  • Yes, I do. When someone set up http://www.website.com/city-name, I would like the accessible content there. Commented Jan 5, 2013 at 16:56

2 Answers 2

2

After the form is submitted you could redirect your users via PHP redirect, or am i missing something?

header('Location: http://www.website.com/city-name');

But be careful, this can only be used before you send any output!

PHP: header()

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

2 Comments

But for doing this, I need to also have set up the .htaccess, or not? Because without that, I would get just 404 error. But how to correctly set up .htaccess for this?
you dont have to set up .htaccess for this, unless you have any weird rewrites set in it. maybe you could add your .htaccess contents?
0

You could let the submit button run a javascript function. In that javascript function, use

var cityName = document.getElementById("the textarea id").value

to get the value the user typed for the city name. Then redirect to the right page:

window.location='http://www.website.com/' + cityName

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.