gideon prewett Posted September 16, 2009 Posted September 16, 2009 could someone make me a simple switch to change vacation mode on and off i want it to be by itself not in prefrences im trying to make it myself and could do it in seconds if it was in prefrences but ive never made 1 from scratch by itself the sql behind it is $db->query("UPDATE users SET vacation=0 WHERE userid=$userid",$c); $db->query("UPDATE users SET vacation=1 WHERE userid=$userid",$c); i think and if anybody could help i would be very greatfull :thumbsup: Quote
CrazyT Posted September 16, 2009 Posted September 16, 2009 Case case 'vacation': vacation(); break; Link [url="preferences.php?action=vacation"]Vacation Change[/url] Function function vacation() { global $db, $ir; $sql = 'UPDATE users SET `vacation` = '. $ir['vacation'] == 1 ? 0 : 1 .' WHERE userid = '. $ir['userid']; $db->query($sql); echo 'You turned vacation '. $ir['varcation'] == 1 ? 'on' : 'off''; } Note: not tested. Quote
Curt Posted September 16, 2009 Posted September 16, 2009 Im not a great coder but this is what i came up with...its not secure tho...but i tested it and it works fine for V2 <?php require "globals.php"; echo '<h1>TURN VACATION ON/OFF</h> '; if ($_GET['action'] != 'turnon') { } else { $db->query("UPDATE users SET vacation=1 WHERE userid=$userid",$c); echo ' You turned Vacation On.'; } if ($_GET['action'] != 'turnoff') { } else { $db->query("UPDATE users SET vacation=0 WHERE userid=$userid",$c); echo ' You turned Vacation Off.'; } { print "<form method=post action=vacation.php?action=turnon><input type=hidden name=action value=turnon><input type=submit value='Turn On'></form> <form method=post action=vacation.php?action=turnoff><input type=hidden name=action value=turnoff><input type=submit value='Turn Off'> </form>"; } $h->endpage(); ?> Quote
Curt Posted September 16, 2009 Posted September 16, 2009 sorry..i had the topic opened while i coded that...after i posted i noticed yours.. Quote
BlueDevil23 Posted September 16, 2009 Posted September 16, 2009 Which is fine, good thing you're trying :) ... I'm sure the more possibilities gideon has to choose from, the better. Quote
gideon prewett Posted September 16, 2009 Author Posted September 16, 2009 simple switch thanks allot both of u i will work on upgrading curts im still new to coding myself but im doing it all from testing stuff im still yet to read anything about php so its taking me a while and im getting stumped on simple stuff lol :wacko: Quote
Karlos94 Posted September 23, 2009 Posted September 23, 2009 Case case 'vacation': vacation(); break; Link [url="preferences.php?action=vacation"]Vacation Change[/url] Function function vacation() { global $db, $ir; $sql = 'UPDATE users SET `vacation` = '. $ir['vacation'] == 1 ? 0 : 1 .' WHERE userid = '. $ir['userid']; $db->query($sql); echo 'You turned vacation '. $ir['varcation'] == 1 ? 'on' : 'off''; } Note: not tested. Why do you need to use a case and function there? Just but the code needed within the case... You are giving yourself even more to write.. And debug if needed. Quote
CrazyT Posted September 26, 2009 Posted September 26, 2009 Yes i know i done it like that for him, because thats how his preferences his. Quote
Karlos94 Posted September 26, 2009 Posted September 26, 2009 LazyT: Just because his is laid out like that, doesn't mean you have to go for that style.. If he wants it to be that style and I sure most people would agree with me that he should learn PHP and have a half decent attempt at it his self. But it's my view.. Other people may and some will have different views. Quote
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.