PDA

View Full Version : Html Php Form Question


earthsiege
08-24-2004, 01:52 PM
hey guys,
im not sure which room this thread should go in but because i use php a lot i thought id put it here.
right the question i have is when you have a form in a web page and it has action which sends information to a php page can you have multiple submit buttons with the same 'name' but different values.
because if you can then you can manipulate the information from that form in realtion to which button the user pressed.

for example:
you have a form containing ordering information which allows the user to change the quantity of their objects and submit their order or if they want add more objects.
by have two buttons like <input type='submit' name='next' value='Add'>
and <input type='submit' name='next' value='Submit'>
you can go to the php page and update all information changed on the previous page and then you an have something like:
if ($next == Add){
header.....
}
else{
header...more shopping...
}
?>
is this even possible or am i babbling on because if you try this and type something like print($next) on your php page it prints either Add or Submit but doesnt work in the IF statement.

earthsiege
08-24-2004, 01:58 PM
well guys im happy to say that i worked this one out by myself.
you can actually do everyting that i said above but you have to make sure that the values you use in the if statement match the ones in your form and watch out for spaces.

raf
08-24-2004, 02:21 PM
euh. I do that all the time. But the condition needs to look like

if (isset($_POST['action'])){
if ($_POST['action'] == 'Add'){
// whatever
}elseif ($_POST['action'] == 'Delete'){
// whatever
}
}