[nycphp-talk] Can't get no $action
leam
leam at reuel.net
Mon Apr 26 09:36:39 EDT 2004
Dan Cech wrote:
> leam wrote:
>> From the editor_form function:
>>
>> echo "<form name=edit_form method=post action=$PHP_SELF >";
>> echo "<input type=hidden name=action value=save_file >";
>> echo "<input type=submit value='Save and Exit' name=submit>";
>
>
> It won't be causing the problem, but your html should be properly quoted.
Do you mean like:
echo "<input type=\"hidden\">";
or can I use single quotes? Yeah, I'm still on the square part of the
learnin' curve...
>
>> From the switch statement:
>>
>> switch($action) {
>> case "save_file":
>> save_file(); break;
>> default:
>> html_header(); editor_form();
>> html_footer();
>> }
>>
>> The save_file function works if it's called by itself, and the $action
>> just seems to call the default.
>
>
> I would suggest that your server might have register_globals turned off,
> meaning you will need to use $_POST['action'] instead of $action. You
> should do this anyway, rather than relying on register_globals.
>
> Dan
Virtual Drink to you, that was it! Went to switch($_POST[action]) and it
worked.
The book recommends register_globals be on but I've understood that is
not the best solution. However, I still get mixed up in their code
becasue they're using it that way.
Thanks!
leam
More information about the talk
mailing list