hello all, i'm building a CMS and i'm have some trouble with a certain page i've been working on. I have information stored in my database that the admin user can edit and update and change, obviously. on this edit page i have HTML input fields that have been pre-populated with the variable values.

underneath all of that, i have 3 html submit buttons. one of them is "Cancel", another is "Save and Exit", and the last is "Save and Continue".

if the admin presses cancel, i want to keep the values that are already stored in the database, and go to a certain page.

if the admin presses save and exit, i want all the changes that have been made to update the database, and then go to a certain page.

if the admin presses save and continue, i want all the changes that have been made to update the database, and then go to a different page.

got it? how do i do this? i was thinking wrapping it all up in one html form, and replacing action= with action=<?php echo $submit_value ?> or something like that. and on each submit button the name could be the value of $submit_value. maybe with some if() statements. i dunno. help!

If you use regular form submit buttons for each of those "tasks", then you can branch your PHP code using the value of each button..

Eg:

<?php




?>

<form action="handle.php" method="post">


<input type="submit" name="task" value="Cancel" />

<input type="submit" name="task" value="Save and Exit" />

<input type="submit" name="task" value="Save and Continue" />

</form>

If the user clicks on "Cancel", then $_POST will equal, "Cancel".

If the user clicks on "Save and Exit", then $_POST will equal, "Save and Exit", etc.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.