Jump to content
MakeWebGames

Recommended Posts

Posted

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:

Posted

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.

Posted

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();
?>
Posted

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:

Posted
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.
Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...