Reply to Re: Trying to have a state-machine one the page (newbie)

Your name:

Reply:


Posted by Hilarion on 10/10/59 11:25

Jean-Louis Crouzet <jeanlouis.crouzet@free.fr> wrote:
> can't put this problem on line for now (too many .htaccess things).
> Anyhow my goal is to have a state machine on one page which from certain
> <form> results or any other working way will step into a new case
> called from that same page. Not sure to be 100% clear.
>
> Here is the sample code:
>
> // in the beginning of the php file I have
>
> switch ($_POST['action'])
> {
> case "update":
>
> /* Do some stuff...then */
>
> $url = $_SERVER['PHP_SELF'] ;
> echo "<form action=$action method='post'>\n" ;
> echo "<input type='HIDDEN' name='action' value='updated' />\n" ;
> echo "</form>\n" ;
> echo "<script> window.location.replace('$url') </script>\n";

This line above should probably be something like:

echo "<script> window.location.replace('" . $action . "?action=updated') </script>\n";

And dump the <form> in this case (when you use location.replace, then
the form is not submitted, if it doesn't work, then user still can't
submit the form cause you did not provide the submit button).

> break; // Probably useless ???
>
> // This is where I want to go from previous case
> case "updated":
> echo '<p>Updated</p>';
> ShowVar($_POST) ;
> break;
>
> default:
> break;
> }
>
> /* Do some other stuff...then */

The code below should be used only in case $_POST['action'] is not
set, so make it a "default" in your "switch".

> echo "<tr><form action=$url method='post'>\n" ;
> echo "<td><input type='HIDDEN' name='action' value='update' />\n" ;
> echo "<input type='SUBMIT' name='update' value='Change!' /><</form>\n" ;
>
> /... this last submit work and go to update for sure.


Hilarion

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация