|
Posted by Jean-Louis Crouzet on 10/10/49 11:25
Hilarion wrote:
> 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
First thanks Hilarion for your input, I tried your submitted way and
definitely goes towards this
url="http://localhost/site1/menus/dm_menu_admin.php?action=updated" but
even then I do not fall into my case switch as expected, and this is
what I'm trying to achieve. Still investigating.
JL
Navigation:
[Reply to this message]
|