Using radio button to determine further code on same page
Posted: Thu May 28, 2009 12:46 pm
I'm new to PHP but been programming in various other languages since 1970. I may be trying to do something here that PHP won't want to do but it's worth a try. I also have never learned HTML so I'm working on learning that as I go along. So far I'm not having much trouble outside of syntax errors .. but now I am wanting something a little more involved.
Basically I have a pair of radio buttons displayed (Edit/Delete) and based upon the user's selection of these I want to display a submit button either to submit the edit or submit the deletion to a dB. Here's a snippet of the code that is confusing me ... it's all pretty obviously in PHP tags
When I try to run this I get an undefined index error in the last line. What my idea was to try after that is this::
I've only been working with PHP for a couple days so I'm probably not grasping nuances here. My idea is to use 1 page to handle 3-4 jobs instead of coding individual pages for each job. Functions and OOP isn't very hard though the syntax requires a bit of trial and error. So far I've managed to get the one page to edit, delete and add but this code would tend to let me combine the edit and delete into 1 block. But I may be asking it to do too much.
TIA for your help,
Ken
Basically I have a pair of radio buttons displayed (Edit/Delete) and based upon the user's selection of these I want to display a submit button either to submit the edit or submit the deletion to a dB. Here's a snippet of the code that is confusing me ... it's all pretty obviously in PHP tags
Code: Select all
echo "<form action=\"update_gallery.php\" method=\"post\">";
echo "<INPUT TYPE = \"Radio\" Name =\"edit\" value= \"edit\" CHECKED>Edit";
echo "<INPUT TYPE = \"Radio\" Name =\"edit\" value= \"del\" >Delete";
$sel_edit=$_POST["edit"];
Code: Select all
$sel_edit=$_POST["edit"];
{
echo "<input type=\"submit\" value=\"Update Gallery Name\"/>";
} else {
echo "<input type=\"submit\" value=\"Delete Gallery Name\"/>";
}
TIA for your help,
Ken