[Help] Creating check-box in website?

RyDog

Lazy Animal Crossing hacks
OP
Member
Joined
Apr 26, 2015
Messages
1,698
Trophies
1
Age
24
XP
2,850
Country
United States
So I want to create this website that downloads different configs of a NTR plugin, I know how to create checkboxes... but the thing is I want my website to be able to read the input that the user inserts, for example:
screenshot.png

I only want the website to download the custom plugin for Teleport and Speed Hack. (I'll upload all the possible combinations that you can make with this list.)
Would it be setting those check-boxes a variable like A, B, C and D so that it stores those variables, and download the appropriate file to the variable? (ex: since it's Teleport+SpeedHack It'll set the variable to B+D and download B+D.
I'm very new to HTML and in my computer science and software engineering class we only went over HTML for a week so my knowledge is still very weak.
Thanks in advance!
 

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,798
Trophies
3
XP
28,284
Country
United Kingdom
Is it basically a list of 15 premade hacks (I assume there is no point in having a blank hack for none of the options selected) then.

Most people would launch right into a php script ( https://www.formget.com/how-to-redirect-a-url-php-form/ ), maybe javascript, and maybe generate the thing on the fly if they can (though generating binary data with web coding is not the nicest so maybe not). However you could probably code something on the page in javascript to grab the relevant one of 15 files from the server. Javascript is the lesser method but it is also the easier one as it runs on the client's computer and thus your sever merely has to handle HTML and downloading. The checkboxes you mention are part of HTML/web coding known as forms. I am not the greatest fan of w3schools but they do OK here http://www.w3schools.com/html/html_forms.asp

The crazy way of doing it would be to scratch the checbox approach and do a choose your own adventure style nest of links (page 1 "do you want moon jump, yes, no, just moon jump", page 2 "do you want teleport....) and however many pages you need but I am going to get spat at for suggesting that as a path so I will leave it at that. However if that is all you know and you do not want to tangle with javascript and php it will work just fine. It will be a pick to manage and if you have more than about 4 variables it is going to rapidly increase the time needed to make it (it is going to need "2^(number of variables) -1" pages)..

Most of the time when doing a checkbox downloader it is for multiple files rather than this (here is one I found on stackexchange a short while ago http://pastebin.com/nZhNzeMa , http://stackoverflow.com/questions/...iple-files-at-the-same-time-having-checkboxes ). However the simple way would be to assign each of those one of the binary values and use it to count to 16, possibly also adding a sanity check in case you do not have anything selected. In case you are not familiar with using binary like this then here is the full list
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1111
I find some people have trouble using this as a logical progression but it really does cover every value. Apologies if I have stated the obvious -- your lack of HTML/web skills could mean your course has not taught you much, or it could just mean that web stuff was not a priority and I have seen it go both ways.

Assign the first space in the value the moon jump value, second teleport, third duplication, fourth speed hack.
1000 = just moon jump
0100 = just teleport
0010 = duplicaiton
0001 = speed hack
You don't have to do it in binary and it will work just as well in hexadecimal (it is still binary underneath it all), however to explain it I left it in binary.
Anyway so if you add together the values from the checkboxes and get 0011 you know you need duplication and speed and you can download file 3 (0011 = 3 decimal/hex after all). Again like the links this is not a method that scales well but it will work just fine here. If the names of your downloads do not matter (this is for a cheat program so it could go either way) I would just stick it on the download file.

Afraid I am going to have to leave you at theory at this point rather than workable solution, partially because it is late on Friday evening and partially because I am a bit hazy on javascript myself right now.
 

0x40

Well-Known Member
Member
Joined
Apr 20, 2013
Messages
281
Trophies
1
Location
/
XP
807
Country
United States
Something like this?

PHP:
<?php
$opts = "";

if (isset($_POST["moonjump"]))
    $opts .= "_moonjump";

if (isset($_POST["teleport"]))
    $opts .= "_teleport";

/* more ifs */

if ($opts == "")
    die("nope");

header("Location: /path/to/downloads/ntr" . $opts . ".whatever");
?>
 
Last edited by 0x40,

RyDog

Lazy Animal Crossing hacks
OP
Member
Joined
Apr 26, 2015
Messages
1,698
Trophies
1
Age
24
XP
2,850
Country
United States
Wow is this complicated :wacko:, and I think I'm going to use binary variables like what @FAST6191 told me. And @!() I barely know the basics of HTML/PHP, could you please add comments in your code to elaborate what everything does?
Thanks for your help so far guys.
 

0x40

Well-Known Member
Member
Joined
Apr 20, 2013
Messages
281
Trophies
1
Location
/
XP
807
Country
United States
Wow is this complicated :wacko:, and I think I'm going to use binary variables like what @FAST6191 told me. And @!() I barely know the basics of HTML/PHP, could you please add comments in your code to elaborate what everything does?
Thanks for your help so far guys.

PHP:
<?php
$opts = ""; /* variable that will later contain all the checkbox options */

if (isset($_POST["moonjump"])) /* condition that checks if a checkbox was checked in the HTML form. */
    $opts .= "_moonjump"; /* this appends the option to the option string */

if (isset($_POST["teleport"])) /* we do the same thing for every other option */
    $opts .= "_teleport";

/* you can add as many options as you want like this */

if ($opts == "")
    die("nope"); /* error handling if user didn't select any options at all */

header("Location: /path/to/downloads/ntr" . $opts . ".whatever"); /* redirects user, using options string as part of a file path */
?>
 
  • Like
Reactions: RyDog

RyDog

Lazy Animal Crossing hacks
OP
Member
Joined
Apr 26, 2015
Messages
1,698
Trophies
1
Age
24
XP
2,850
Country
United States
PHP:
<?php
$opts = ""; /* variable that will later contain all the checkbox options */

if (isset($_POST["moonjump"])) /* condition that checks if a checkbox was checked in the HTML form. */
    $opts .= "_moonjump"; /* this appends the option to the option string */

if (isset($_POST["teleport"])) /* we do the same thing for every other option */
    $opts .= "_teleport";

/* you can add as many options as you want like this */

if ($opts == "")
    die("nope"); /* error handling if user didn't select any options at all */

header("Location: /path/to/downloads/ntr" . $opts . ".whatever"); /* redirects user, using options string as part of a file path */
?>
Ok so what should I do with the HTML so that it uses the PHP for the checkboxes?

--------------------- MERGED ---------------------------

This is what I'm using for my HTML right now:
HTML:
<!DOCTYPE html>
<html>
<body>

  <input type="checkbox" name="cheat" value="0001"> Moon Jump <br>
  <input type="checkbox" name="cheat" value="0011"> Teleport <br>
  <input type="checkbox" name="cheat" value="0111"> Duplication <br>
  <input type="checkbox" name="cheat" value="1111"> Speed Hack <br>
  <input type="submit" value="Submit">
</form>

</body>
</html>
 

0x40

Well-Known Member
Member
Joined
Apr 20, 2013
Messages
281
Trophies
1
Location
/
XP
807
Country
United States
Ok so what should I do with the HTML so that it uses the PHP for the checkboxes?

--------------------- MERGED ---------------------------

This is what I'm using for my HTML right now:
HTML:
<!DOCTYPE html>
<html>
<body>

  <input type="checkbox" name="cheat" value="0001"> Moon Jump <br>
  <input type="checkbox" name="cheat" value="0011"> Teleport <br>
  <input type="checkbox" name="cheat" value="0111"> Duplication <br>
  <input type="checkbox" name="cheat" value="1111"> Speed Hack <br>
  <input type="submit" value="Submit">
</form>

</body>
</html>
Put checkboxes in a form element with method="POST" and action="/path/to/phpscript.php", and make sure checkboxes have name corresponding to that in the PHP script (the $_POST[""] part in the ifs.) You don't need the value attributes.
 
Last edited by 0x40,

RyDog

Lazy Animal Crossing hacks
OP
Member
Joined
Apr 26, 2015
Messages
1,698
Trophies
1
Age
24
XP
2,850
Country
United States
Put checkboxes in a form element with method="POST" and action="/path/to/phpscript.php", and make sure checkboxes have name corresponding to that in the PHP script (the $_POST[""] part in the ifs.) You don't need the value attributes.
So far my HTML is:
HTML:
<!DOCTYPE html>
<html>
<body>
<form action="c" method="POST">
  <input type="checkbox" name="moonjump" value="0001"> Moon Jump <br>
  <input type="checkbox" name="teleport" value="0011"> Teleport <br>
  <input type="checkbox" name="dupe" value="0111"> Duplication <br>
  <input type="checkbox" name="speed" value="1111"> Speed Hack <br>
  <input type="submit" value="Submit">
</form>

</body>
</html>
PHP is:
Code:
<?php
$opts = ""; /* variable that will later contain all the checkbox options */

if (isset($_POST["moonjump"])) /* condition that checks if a checkbox was checked in the HTML form. */
    $opts .= "_moonjump"; /* this appends the option to the option string */

if (isset($_POST["teleport"])) /* we do the same thing for every other option */
    $opts .= "_teleport";

/* you can add as many options as you want like this */

if ($opts == "")
    die("nope"); /* error handling if user didn't select any options at all */

header("Location: /downloads/cheat.plg" . $opts . ".whatever"); /* redirects user, using options string as part of a file path */
?>
and when I select any of the cheats and click submit it tries directing me to a /c directory?
screenshoot.png
 

0x40

Well-Known Member
Member
Joined
Apr 20, 2013
Messages
281
Trophies
1
Location
/
XP
807
Country
United States
The action attribute is where it directs you when you click submit. Change it to where the PHP script is.
 

RyDog

Lazy Animal Crossing hacks
OP
Member
Joined
Apr 26, 2015
Messages
1,698
Trophies
1
Age
24
XP
2,850
Country
United States
The action attribute is where it directs you when you click submit. Change it to where the PHP script is.
whoops, thought I meant to paste and accidentally must've pressed c, good find ;)
I think I finally get how the php you provided functions now. One last question, can I change the underscores from this "The requested URL /downloads/_moonjump_teleport.whatever was not found on this server." to '/' so I can organize the database?
 

0x40

Well-Known Member
Member
Joined
Apr 20, 2013
Messages
281
Trophies
1
Location
/
XP
807
Country
United States
You could, but you'd end up with a lot of folders that way. It's simpler just to organize them by file name and have them all in a single folder.
 

RyDog

Lazy Animal Crossing hacks
OP
Member
Joined
Apr 26, 2015
Messages
1,698
Trophies
1
Age
24
XP
2,850
Country
United States
You could, but you'd end up with a lot of folders that way. It's simpler just to organize them by file name and have them all in a single folder.
That's kinda how I want it because with NTR plugins, it uses cheat.plg, so I can't put all of these files in the same directory.
 

0x40

Well-Known Member
Member
Joined
Apr 20, 2013
Messages
281
Trophies
1
Location
/
XP
807
Country
United States
You could do something like
PHP:
header("Location: /downloads/cheat" . $opts . "/cheat.plg");
and have a directory for every file.
 

RyDog

Lazy Animal Crossing hacks
OP
Member
Joined
Apr 26, 2015
Messages
1,698
Trophies
1
Age
24
XP
2,850
Country
United States
That's kinda how I want it because with NTR plugins, it uses cheat.plg, so I can't put all of these files in the same directory.
Ok currently I'm using a Amazon server that was provided for a lesson we did in my computer science class, so when I use this code:
PHP:
header("Location: /downloads/" . $opts . "cheat.plg"); /* redirects user, using options string as part of a file path */
it tries going to the root of the server:
error1.png

and using
Code:
header("Location: ~mazzn6gd/downloads/" . $opts . "cheat.plg"); /* redirects user, using options string as part of a file path */
directs me to:
error2.png

which is not where I want it to go to. I want it to go to http://cse-www.pltw.org/~mazzn6gd/downloads/moonjump/cheat.plg

--------------------- MERGED ---------------------------

I'm moving this server once I figure everything out, but for now I'm using that server as a test
 

0x40

Well-Known Member
Member
Joined
Apr 20, 2013
Messages
281
Trophies
1
Location
/
XP
807
Country
United States
If the PHP script is in /~mazzn6gd, you can use Location: downloads/ without the / at the beginning and it will use the directory relative to where the script is.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
  • Veho @ Veho:
    The fuuuuu---
  • Veho @ Veho:
    I thought it was an actual xBox at that price.
  • Sicklyboy @ Sicklyboy:
    I wanna grab a 360 Slim and a 360 E one of these days. Missed the boat of getting them at their lowest though, once they were discontinued. Could've got them for cheap back when I was a broke 20 something working at Target, but then again, I was a broke 20 something working at Target
  • Veho @ Veho:
    Being broke is no fun.
  • K3Nv2 @ K3Nv2:
    @Sicklyboy, $150 isn't that bad for a jtag slim on ebay
  • Veho @ Veho:
    I only wish it was actually playable.
  • Veho @ Veho:
    There's a guy on the Tube of You that makes playable mechanical arcade games out of Lego. This could work on the same principle.
  • Veho @ Veho:
    Just a couple of guys taking their manatee out for some fresh air, why you have to molest them?
  • Veho @ Veho:
    Stupid Chinese shop switched their shipping company and this one is slooooooow.
  • LeoTCK @ LeoTCK:
    STOP BUYING CHINESE CRAP THEN
  • LeoTCK @ LeoTCK:
    SUPPORT LOCAL PRODUCTS, MAKE REVOLUTION
  • LeoTCK @ LeoTCK:
    THEY KEEP REMOVING LOCAL SHIt AND REPLACING WItH INFERIOR CHINESE CRAP
  • LeoTCK @ LeoTCK:
    THATS WHY MY PARTNER CANT GET A GOOTWEAR HIS SIZE ANYMORE
  • LeoTCK @ LeoTCK:
    HE HAS BIG FOOT AND BIG DUCK
  • LeoTCK @ LeoTCK:
    d*ck i mean*
  • LeoTCK @ LeoTCK:
    lol
  • Veho @ Veho:
    Mkay.
  • Veho @ Veho:
    I just ordered another package from China just to spite you.
  • SylverReZ @ SylverReZ:
    Communism lol
  • SylverReZ @ SylverReZ:
    OUR products
  • The Real Jdbye @ The Real Jdbye:
    @LeoTCK actually good quality products are dying out because they can't compete with dropshipped chinese crap
    +1
    The Real Jdbye @ The Real Jdbye: @LeoTCK actually good quality products are dying out because they can't compete with dropshipped... +1