Darkmatter5 Posted April 13, 2009 Share Posted April 13, 2009 I have a script that runs inside a form that generates 2 buttons per record. From a query I get a list of users on my site, and create 2 buttons either "activate$member_id" or "deactivate$member_id" and either "suspend$member_id" or "unsuspend$member_id" These buttons are dependent on if the particular member is activated=0 or 1 and if the member is suspended=0 or 1. So I need a script that can handle all instances of these buttons for each member_id. So basically. For member 4 if(isset($_POST['activate4'])) { run this code } if(isset($_POST['deactivate4'])) { run this code } if(isset($_POST['suspend4'])) { run this code } if(isset($_POST['unsuspend4'])) { run this code } How should I go about making code that handles these dynamic instances? Quote Link to comment Share on other sites More sharing options...
dbemowsk Posted October 27, 2009 Share Posted October 27, 2009 I don' know that this is exactly what you are looking for, but it might work. . I needed a way to dynamically create web buttons for a web based application I am creating. I created a script that takes a number of parameters to create dynamic consistent looking web buttons on the fly. Pass your text, icon, a set of 3 background images, along with a few other config options, and get buttons like these. http://www.phpwebscripting.com/scripts/button/button.php?bl=bl_green.png&br=br_green.png&bg=bg_green.png&ico=group_key.png&ft=default.ttf&txt=Dynamically%20created&bsln=3&fcr=102&fcg=255&fcb=165&fs=10&ind=2 The buttons shown above were created using the demo of the script. Read the tutorial and try the demo at http://www.phpwebscripting.com/index.php?module=article&view=8 I hope this is useful Quote Link to comment Share on other sites More sharing options...
akitchin Posted October 27, 2009 Share Posted October 27, 2009 I have a script that runs inside a form that generates 2 buttons per record. From a query I get a list of users on my site, and create 2 buttons either "activate$member_id" or "deactivate$member_id" and either "suspend$member_id" or "unsuspend$member_id" These buttons are dependent on if the particular member is activated=0 or 1 and if the member is suspended=0 or 1. So I need a script that can handle all instances of these buttons for each member_id. So basically. For member 4 if(isset($_POST['activate4'])) { run this code } if(isset($_POST['deactivate4'])) { run this code } if(isset($_POST['suspend4'])) { run this code } if(isset($_POST['unsuspend4'])) { run this code } How should I go about making code that handles these dynamic instances? i would suggest a different way of structuring your forms. since your user will only be hitting one of these buttons at a time, why not nestle each one of them into their own unique form with a hidden input that designates the member's id and action to be taken? for example: <form action="whatever.php"> <input type="hidden" name="member_id" value="MEMBER_ID_ECHOED_HERE" /> <input type="hidden" name="action_to_take" value="ACTIVATE_OR_DEACTIVATE|SUSPEND_OR_UNSUSPEND" /> <input type="submit" name="submit" value="ACTIVATE_OR_DEACTIVATE|SUSPEND_OR_UNSUSPEND MEMBER MEMBER_ID_ECHOED_HERE" /> </form> this requires really only one processing function, which looks in $_POST['action_to_take'] for the procedure to perform, and $_POST['member_id'] for the id of the member on whom the operation should be performed. it should be noted that the user can change any of these POST values, so it would be wise to make sure you run checks to verify that the operation is possible for the given member (eg. that they aren't trying to unactivate an inactive user). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.