/    Sign up×
Community /Pin to ProfileBookmark

Using POSTS vs GETs

I have written alot of my web site and have sometimes used a form Post to call a new php script and sometimes used href.

I didn’t like the fact that you can see all the variables in the browser with href so didn’t use the GET so much.

Just read somewhere that GETS should be used mainly for linking.
I now realise that POSTS are not really any more secure than GETS

What are the rules or recommendations on this ?

Considering the issue from a search engine ranking viewpoint.

I guess that it would definitely be better to use href (GET) to move from page to page rather than using a Button in a form ( and passing necassary data with POST )

I am thinking about navigation form-buttons – vs href links

I understand that Favorites and Bookmarks will also work better if the page is ‘href’ed instead of Form-action = xxxx.php (ie POSTED)

What does every one think about this ?

to post a comment
PHP

12 Comments(s)

Copy linkTweet thisAlerts:
@GarySJun 04.2006 — Read something recently that I'd been applying (mostly...) but had never really thought about. It went something like:

Use POST when the the world has changed.

So when someone submits a form: POST. If someone wants a different view of the page they are already viewing - perhaps by changing the sort order - that's a job for GET.

There is a search consideration: search engines can't "get past" a POST. Although most search eingines can cope with GET, I prefer to avoid them for my main web pages (saving them for things like sort order/printer-friendly versions)

That's my two-penneth.
Copy linkTweet thisAlerts:
@DaveinLondonauthorJun 05.2006 — The site I am working on is at

http://www.yodbod.com

and as you can see it is mainly buttons rather than hrefs.

I guess that I should change it ?

Actually the whole design is changing anyway ! ?
Copy linkTweet thisAlerts:
@DaveinLondonauthorJun 05.2006 — What does anyone think of this

www.yodbod.com

shold all the buttons really be hyperlinks for better SEO ?
Copy linkTweet thisAlerts:
@GarySJun 05.2006 — Dave - Sorry, meant to get back to you earlier.

As things stand, no search engine will be able to follow your "main navigation". Here are the only pages the search engines will be able to index:

http://www.yodbod.com/

http://www.yodbod.com/ad_contact.php?b=London&c=f&d=A&e=&f=loc_sht&g=0&h=1

http://www.yodbod.com/ad_epostcard2.php?b=London&c=f&d=A&e=&f=loc_sht&g=0&h=1

http://www.yodbod.com/index1.php

http://www.yodbod.com/a_who.php

http://www.yodbod.com/ad_epostcard2.php

http://www.yodbod.com/a_terms.php

http://www.yodbod.com/index.php

http://www.yodbod.com/ad_epostcard2.php?b=$sel_city&c=$sel_area&d=$sel_cat&f=$sorter&g=$start&h=$page_counter


So, yes, you should switch these over to hyperlinks. Note that there's no real reason to pass all the parameters you're passing: these would normally "live" in the target page. (Post again if that needs further explanation)
Copy linkTweet thisAlerts:
@pcthugJun 05.2006 — ...shold all the buttons really be hyperlinks for better SEO ?[/QUOTE]Yes. Static pages preferably.
Copy linkTweet thisAlerts:
@DaveinLondonauthorJun 05.2006 — Thanks very much for your replies !

The reason for passing all the variables is so that the select and sort preferances (eg north of the city) are kept even when the client changes the main table.

Also I do know if I can convert the select and sort from a form to a hyperlink can I ???

Much appreciate any further guidance ?
Copy linkTweet thisAlerts:
@GarySJun 05.2006 — Would this work:

Let's say the jobs page is called jobs.htm. It has a default state (i.e., the way it appears before any selections have been made. Once a selection has been made, there are two main ways to tell jobs.htm about it:

  • 1. via the query string. (Note that this does NOT mean using a form!) For example jobs.htm?region=north


  • 2. via a session. Although this might sound complicated, if you want to pass things like "north of city" around the website, it might save you time in the long run.


  • Back to the jobs.htm page: At the top of the page, you need to look for the query string (or the session values) and serve the page accordingly.
    Copy linkTweet thisAlerts:
    @DaveinLondonauthorJun 05.2006 — Your query string is another way of saying using GET[]

    isn't it ( as in POSTS vs GETS )

    One reason against using the GET method is that I want to pass this data around and I heard ( a year ago) that if the url is too long then some of the info could get dropped off.

    That is why I started using single letters for the variable names. I do use a GET for the detail pages e.g.

    jobs_detail.php?a=$ad_ref&b=$sel_city&c=$sel_area&d=$sel_cat&e=$section&f=$sorter&g=$start&h=$page_counter

    I would prefer to use more meaningful names (instead of a b c d etc. ) but I was worried about the 'dropping off' possibility. ???


    Yes, I was thinking about using sessions

    Is the session variable an array holding all the info ?

    Could I use it to pass this kind of info ?
    Copy linkTweet thisAlerts:
    @GarySJun 05.2006 — Sorry, yes: you access query strings using $_GET.

    Not sure about the max limit on the length of the query string - I've seen some pretty long ones out there.

    You're going to need to be careful, search engine-wise, if you go with query strings. There's a real danger that it will look like your site is composed on a lot of very similar pages.

    Sessions are the answer to pretty well all of the above. They do work a lot like arrays - ideal for what you're trying to do.
    Copy linkTweet thisAlerts:
    @DaveinLondonauthorJun 05.2006 — Great - I'll look into it some more.

    Obviously my pages are for adverts and they are held in mysql database so they will similar.

    I was happy with the $_POST but I guess I will have to use sessions.

    I guess that I then just pass the session id with each string..GET ?
    Copy linkTweet thisAlerts:
    @GarySJun 05.2006 — You don't need to manipulate the GET to use sessions. Check out this introduction to using sessions: http://www.phpfreaks.com/tutorials/41/0.php
    Copy linkTweet thisAlerts:
    @DaveinLondonauthorJun 05.2006 — Thanks - I bookmrked it and will work through pretty soon.
    ×

    Success!

    Help @DaveinLondon spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.3,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,

    tipper: @Samric24,
    tipped: article
    amount: 1000 SATS,
    )...