SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Changing URL

  1. #1
    SitePoint Addict
    Join Date
    Jun 2005
    Posts
    294
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Changing URL

    I have a submit form that after you submit your selection it has a really long URL in the address bar.. I wanted to know.. How would I go about taking all my actions out of the address bar and simply displaying www.webpage.com/page

    Instead of

    http://webpage/?cs-action=coupons.vi...host&company=3

  2. #2
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    Williamsport, PA
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    GET or POST Request?

    Looks to me like your form is being submitted via a GET request. If you are famililar with the idea I apologize for being long-winded I'll give the solution to your problem immediately. You can read the theory if you want. I'll include it below.

    Chances are your <form> tag either looks like one of the following:

    Code:
    <form action="..."> ... </form>
    Code:
    <form method="GET" action="..."> ... </form>
    method="GET" means that your form will submit via an HTTP GET request, and not assigning a method defaults to GET. What you want is a POST request.

    Code:
    <form method="POST" action="..."> ... </form>
    Change the form method to POST and you should get the result you desire. I'll explain why:

    There are several types of HTTP requests, each more specifically suited to a different job. A GET request will include all of the information needed to load the requested page directory in the URL. All that extra information you are seeing is what's called a "query string." It contains a URL-encoded version of all that data entered into your form. The thing to remember is that GET request sizes are limited (a maximum if 1k or 1024 bytes of data I think), and will display all the data submitted in a more-or-less human-readable format in the address bar. Form submissions via GET are ugly, unsafe (visually anyway), and unsuited to larger form submissions.

    There is another type of HTTP request called a POST. The POST request will request the form's action URL and that URL only will display in the address bar of the browser. The submitted form data is submitted in a different part of the request, totally transparent to the user. POSTed data is invisible to the user, and better-suited to larger form submissions.

  3. #3
    SitePoint Zealot sajjad's Avatar
    Join Date
    May 2005
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use $_GET for this sort of stuff
    If you lose your patience you lose half of battle


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •