Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Following example is part of a response at the following url.
- // http://www.hamsterpaj.net/diskussionsforum/gaa_till_post.php?post_id=4265149
- // Items to iterate through (sql-key => post-value)
- $postItems = array(
- 'newsadmin',
- 'forumpolis',
- 'moderator',
- 'memberadmin',
- 'superadmin'
- );
- // Check if each individual item is set and assign an integer for state
- // User altered information will be disregarded and changed to either a 0 or 1
- // depending on the key being assigned or not, so no filtering necessary
- foreach ($postItems as $postItem){
- $_POST[$postItem] = (!isset($_POST[$postItem])) ? 0 : 1;
- }
- // Cast userID to an integer only, non-numerical information will return 0
- $_POST['userID'] = (int)$_POST['userID'];
- // Construct query
- $sql = 'UPDATE user_groups SET news='.$_POST['newsadmin'].', forum='.$_POST['forumpolis'].', moderator='.$_POST['moderator'].', user='.$_POST['memberadmin'].', super='.$_POST['superadmin'].' WHERE userID='.$_POST['userID'];
- // Dump variable
- var_dump($sql);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment