Jump to content


Appending user inputted text to a URL?


4 replies to this topic

#1 chan_boy

    Young Padawan

  • Members
  • Pip
  • 2 posts

Posted 17 November 2007 - 02:01 PM

Hey,

I'm a bit of a newbie to coding and web programming so I hope you guys can point me in the right direction!

What I would like to do is create a web form with text boxes / drop down menus and when the user hits a submit button it opens a new page with the elements from the form creating a URL.

ie

Please enter your details:

Text box: __a__
Text box: __b__
Drop down: C Drop down: D

(submit)

which then opens a new page with the URL "http://www.mypage.com/a/b/c/d"

I'd be grateful for any help that you can give me :-)

Thanks in advance,
Jack

Edited by chan_boy, 17 November 2007 - 02:01 PM.


#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 17 November 2007 - 04:39 PM

<form method="get">
The rest is handled automatically.

Edited by rc69, 17 November 2007 - 04:40 PM.


#3 chan_boy

    Young Padawan

  • Members
  • Pip
  • 2 posts

Posted 17 November 2007 - 07:18 PM

View Postrc69, on Nov 17 2007, 04:39 PM, said:

<form method="get">
The rest is handled automatically.

You're probably gonna think I'm very stupid...but with that isn't there a '?' in the url ie a query which inputs into something else. All I need is a url output...no querying or anything. If there was any way to take the '?' out then this would be perfect.

Thanks :-)

#4 curthard89

    Young Padawan

  • Members
  • Pip
  • 226 posts

Posted 20 November 2007 - 03:33 AM

if u want to take the ? or dont see crap looking url's then use mod_rewrite, plenty of tutorials around for it :rolleyes:

#5 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 20 November 2007 - 12:55 PM

Ahh, but the trick is getting a form to submit the data without appending the query string to the url. For that, mod_rewrite doesn't help at all, it's what happens after the url is formatted correctly that you need mod_rewrite for.

Just loop through the form elements and concatenate them all into a string seperated by the slashes. Then set window.location.href equal to the string (like mod_rewrite, i'm sure you'll be able to find some tutorials for how to do the various things needed).





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users