/    Sign up×
Community /Pin to ProfileBookmark

Forms and Buttons for navigation. What’s the best option

This question is an HTML/php mix…

I am designing a screen which is basically an HTML form. It’s the first one I have done, but it seems OK. As part of the form I want to have a cancel button which will take the user back to the home page.

While researching how best to code the form I have seen at least 3 different strategies for handling this type of navigation.

Option 1: A form submit button, with associated php handling….
<input type=’submit’ name=’cancel’ value=’Cancel’ />

// php handling…..
if (array_key_exists(“cancel”, $_POST)) {
header(‘Location: home.php’ );
exit;
}

Option 2: A standard form button
<input type=’button’ name=cancel2′ value=’Cancel2′
onclick=”window.location.href=’home.php'”>

Option 3: Use an href – the button will be an image, so this sould be fine too

The question is which of these should be the preferred solution in a php/html/css web app.

Does it just come down to preference or are there some situations in which an option will not perform well in terms of security, performance, ease of css styling, maintainability etc…

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@MindzaiApr 09.2009 — Forms should not be used for navigation. An <a> is the correct tool for this job.
×

Success!

Help @CJM1968 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,
)...