Re: buttons and "action"



On Nov 23, 6:02 am, richard <mem...@xxxxxxxxxxx> wrote:
<form id="chooser" action="chooser.php" method="post">

<button type="submit" name="plan" value="basic">

On my web page I'm building I will have a two column layout with header.
The left column will have the menu which I think I can do better with
buttons. What all can I do with "action"?
As that is obviously the key to making it all work when a button is clicked
on.

When the page loads, an initial page loads in the right column.
When user clicks a button, that page is changed. I've seen this done before
so I know it will work.

So how do I pass a value on to the next step?

For instance, my variable will be named $item.

<?PHP
if ($item=="basic"){echo "basic"}

?>

Yeah, I'd have to say that a switch statement would be best in this
scenario. You can pass the values through the url (ex: www.yourwebsite.com?p=basic).


<?PHP

if (isset($_GET['p'])) {
$p = $_GET['p'];
} elseif (isset($_POST['p'])) {
$p = $_POST['p'];
} else {
$p = NULL;
}

switch ($p) {

case 'basic';
$page = 'basic.html';
break;

case 'advanced';
$page = 'advanced.html';
break;

default:
$page = 'basic.html';
break;
}

include ('pages/' . $page);

?>


http://php.net/manual/en/control-structures.switch.php
.



Relevant Pages

  • Re: buttons and "action"
    ... On my web page I'm building I will have a two column layout with header. ... When the page loads, an initial page loads in the right column. ... <?PHP ...
    (comp.lang.php)
  • Re: buttons and "action"
    ... On my web page I'm building I will have a two column layout with header. ... When the page loads, an initial page loads in the right column. ... really want to do it with PHP then use differently named input ...
    (comp.lang.php)
  • buttons and "action"
    ... On my web page I'm building I will have a two column layout with header. ... When the page loads, an initial page loads in the right column. ... <?PHP ...
    (comp.lang.php)
  • Re: require_once and fatal errors... automatic sleep and try again anyone?
    ... > I have a PHP page which loads OK 80% of the time. ... the PHP code makes the HTTP response ... That generates a warning instead of a fatal ...
    (comp.lang.php)
  • Re: [PHP] why so slow?
    ... I don't think it's very consistent. ... Sometimes it loads pretty fast and sometimes it gets stuck in the right corner! ... Should the page load as slowly as before, it might have to do with PHP. ... scalable system for accessing system services | ...
    (php.general)