Hi there. I have 4 buttons on the same form- add, edit, delete and cancel button. When user select the course he wanted from the list box, the values are displayed in the textboxes. When user clicked on add button, i need to insert some records which the user has typed into the database. And if the user clicked on the edit button, i would need to update the new infomation that the user has typed into the database. So, I would like to ask how can i idenfy which button the user has clicked on so as to perform certain actions?
I tried using hidden values, but it didnt work.
Below is my code:
<form method = "post" action = "course.php">
<input type = "button" value="add" name="Add">
<input type = "button" value="edit" name="Edit">
<input type = "button" value="delete" name="Delete">
<input type = "submit" value="cancel" name="Cancel">
<input type = "hidden" value="add" name="Add">
<input type = "hidden" value="edit" name="Edit">
<input type = "hidden" value="delete" name="Delete">
<input type = "hidden" value="cancel" name="Cancel">
if ($checkStatus = $POST_['add']){
$insertCourse = "insert into Course (name, country, speaker) values ($name, $country,$speaker)";
$exeInsertCourse = mysql_query($insertCourse);
}
if ($checkStatus = $POST_['edit']){
$editCourse = "update Course set (name = $name, country=$country, speaker=$speaker)";
$exeEditCourse = mysql_query($editCourse);
}
if ($checkStatus = $POST_['delete']){
$deleteCourse = "delete from Course where c_id = $c_id";
$exeDeleteCourse = mysql_query($DeleteCourse);
}
Can anyone help me? Thanks.