Discussions
Categories
Groups
Advertisement
Child Item
Home
Topics
Technology & Internet
Software & Web Development
Design
HTML & PHP Question
maco
Hi,
I have a problem on ,y page where I have two input bottons, one for Update and one for Delete. I need to set a flag,
U
for update and
D
for delete.
What I ahve done so far in my Update botton my setting is this
<input name="update" type="submit" values="update" onclick="<?php $_SESSION = 'U'; ?>"
While my delete botton;
<input name="delete" type="submit" values="delete" onclick="<?php $_SESSION = 'D'; ?>"
Whenever I press update botton still giving me a flag of
D
, is this possible ? or is there any othe way to do it ?
Please help and thanks . . . .
Find more posts tagged with
Quick Links
All Categories
Recent Posts
Activity
Unanswered
Groups
Best Of
Advertisement
Advertisement
Comments
forbairt
You're mixing up twoish things here ...
Server Side and Client Side ...
maco
thanks, still new to this, so this is not possible then ... is there other way to set the flag ?
Serbian
You need to do something like this:
[php]<?php
if ( $_SERVER == 'POST' ) {
$submit = $_POST;
if ( $submit == 'Update' ) {
print 'You clicked Update.';
}
else if ( $submit == 'Delete' ) {
print 'You clicked Delete';
}
}
?>
<form method="post" action="<?php print $_SERVER; ?>">
<input type="submit" name="submit" value="Update" />
<input type="submit" name="submit" value="Delete" />
</form>[/php]
democrates
Remove the javascript from the html.
Change the values attribute to value on each submit button.
In the php script handling the form submission, retrieve the value from each button with something like
$update = $_POST;
$delete = $_POST;
and use a switch command to handle as appropriate.
Edit: Or as Serbian posted! (beat me to it)
forbairt
sorry for the lack of a solution in my response last night ... was busy .. but you've got other responses in the meantime that look good
maco
Guys, thank you very much, I will try that tonight, let you know the outcome.
DOLEMAN
If you're new to PHP I highly recommend this book -
http://www.amazon.com/gp/product/0672326728/sr=8-1/qid=1148676981/ref=pd_bbs_1/103-1920949-5241460?%5Fencoding=UTF8
It'll bring you up to speed in no time.