Jump to content

Tenaciousmug

Members
  • Posts

    159
  • Joined

  • Last visited

Everything posted by Tenaciousmug

  1. I can't figure out how to select something from the database that is under today's date. This is what I have: if($row['date'] == ".date('Y-m-d').' 00:00:00'."' AND date < '".date('Y-m-d').' 23:59:59'.") Any help would be greatly appreciated.
  2. yeah i know. a friend helped me with that part a long time ago and i never really changed it yeah for some reason, its just not working... it already displays the whole code. when i want when you hit the Play button, I want it to lead to a separate page.. like not one that is in the public_html, but with the funky URL. you know how it would say sixdice.php?roll and a whole lot of other junk. thats from the GET method, I know. even before the play button is hit to lead to that php code, it is already showing it underneath the play button. i want it to lead to separate page where they can start playing the game. i dont know how to explain myself. i mean i could give you alink to the page, but you have to register in order to view it because thats how i coded all the pages.
  3. Ok my question is, when they hit the "Play!" button, then I want the php code below to pop up. Like... i think I would use the GET method, but I'm not sure still. I don't think that really matters what method you use, but how do I say IF they click on the "Play" button, then lead them to this code so they can start playing the game. I'm entering this into the database, but I'm just trying to get this code first. I already know how to make it lead to the database and whatnot. <?php session_start(); include("logincheck.php"); ?> <?php include_once("header.php"); ?> <br> Welcome to the Six Dice game. <br><br><b>Instructions</b>: You play this game by randomly rolling a dice. If you land on 1-5, you earn 0 rp. If you land on a 6, you earn 500rp! The game is free so why not give it a shot? <br>You may only play this game 25 times a day! <br><br><form action="sixdice.php?roll" method="post"> <input type="submit" name="playsix" value="Play!" /> </form> <?php if(isset($_POST['playsix'])); $dice = rand(1,6); echo "You rolled a<br /><b>{$dice}</b>\n"; $winnings = "500"; if($dice == 6) { include("haha.php"); $cxn = mysqli_connect($dbhost,$dbuser,$dbpassword,$dbdatabase); $username = $cxn->real_escape_string($_SESSION['username']); $sql = "UPDATE `Member` SET `rp` = rp+$winnings WHERE `username` = '$username'"; mysqli_query($cxn,$sql); }?> <FORM ACTION="sixdice.php" METHOD="post"> <INPUT TYPE="submit" VALUE="Roll Again!" /> </FORM> <?php include_once("footer.php"); ?>
  4. Oh so is different databases when you have more than one different domain? So I should put "Site" Database. Then create Pet Table Item Table etc.?
  5. Is it smarter to make whole seperate databases. I'm creating a virtual petsite. And I want the item database, member database, pet database.. Should I make them whole seperate databases? Or make one database and make them different tables in that one database?
  6. Yeah I already saw that. There was a lot of mistakes punctuation wise. Thanks everyone for replying! It works along with the image verification code.
  7. It still gives me that. x_x I already had it added in. -looks over code again- edit Are you sure this is how you code when selecting two fields from the database? This is the part that has to be throwing it off: $sql = "SELECT username, password FROM Member WHERE username='$username' AND password='$old_password";
  8. Wildteen, everytime I try to use your code.. it just says "Query died: password". It's not going through. Pika, yours wont even let me change it anymore when I do that.. x_x I'm so confused.
  9. I'm trying to let the users change their password, but everytime I try.. it just changes the password to what they type in whether or not the password they currently have is right or not.. x_x I have the password set as an MD5 so I'm guessing I have to select the password from the database as an MD5, but I don't know how to do that.. <?php include("logincheck.php"); $newpass = $_POST['newpass']; $username = $_SESSION['username']; $password = $_POST['password']; ?> <?php include_once("header.php"); ?> Welcome to your settings. This is where you can manage everything on your account! <br><br>----------<b>Change Password</b>---------- <form action="<?php echo $_SERVER['SCRIPT_NAME']?>" method="post"> <?php $type = "text"; echo " <p>Type your current password:<br> <input size='25' name='password' type='$type'></input></p> <p>Type your new password:<br> <input size='25' name='newpass' type='$type'></input></p> <p>Verification:<br> <img src='randomimage.php'><br> <input name='txtNumber' type='text' id='txtNumber' value=''> <br>"; ?> <input type="submit" name="changepass" value="submit" /> </form> <?php if (@$_POST['changepass']) { include("haha.php"); $cxn = mysqli_connect($dbhost,$dbuser,$dbpassword,$dbdatabase); $sql = "SELECT `password` FROM `Member` WHERE `username`='$username'"; $result = mysqli_query($cxn,$sql) or die("Query died: password"); if($result = $password) //password matches { $number = $_POST['txtNumber']; if (md5($number) == $_SESSION['image_random_value']) { $sql = "UPDATE Member SET password = md5('$newpass') WHERE username = '$username'"; mysqli_query($cxn,$sql) or die("Query died: update"); }}} ?> <?php include_once("footer.php"); ?>
  10. Wait. Omg I'm so sorry for doing this. Just a random question, how do you make it so when you hit a button, it will update the roll count in the database without actually.. posting something. I know how to add a pet into a database using a form. BUUT just randomly clicking a button and adding that rollcount + 1 into the database. As you can see, I have : <?php if(@$_POST['sixdice']) { include("haha.php"); $cxn = mysqli_connect($dbhost,$dbuser,$dbpassword,$dbdatabase); $userid = $_SESSION['userid']; $add = "1"; $sql = "UPDATE Sixdice SET rollcount = rollcount+$add WHERE userid = '$userid'"; mysqli_query($cxn,$sql); } }else{ echo "you have already played this game 20 times"; } ?> I have everything correct, BUT the if(@$_POST['sixdice']) x_x Im just so confused on this.
  11. IGNORED THIS TOPIC. I FOUND A LOT OF ERRORS! xD i am redoing the whole table for this game and such. I will probably make a new topic.
  12. Also a simple question that would be helpful on this other part: <?php include("haha.php"); $cxn = mysqli_connect($dbhost,$dbuser,$dbpassword,$dbdatabase) or die("Couldn't connect to server"); $today = date("Y-m-d"); $userid = $_SESSION['userid']; $sql = "SELECT userid FROM Sixdice WHERE rolltime='$today'"; $result = mysqli_query($cxn,$sql) or die(mysqli_error($cxn)); $row = mysqli_fetch_array($result); if($row['rolltime'] > 20) { ?> Very simple code. Buuut I want to know how you can SELECT $userid FROM Sixdice WHERE rolltime='$today'"; I want to select the $_SESSION[userid], but how do I type that variable into the string?
  13. I think I'm using the wrong method, but GET and POST don't seem to fit in at all. I'm making a random game where they can only play 20 times a day. Once they hit that roll again button, I want a string to go into the database. And then after that, I will pull all those.. whatever I know how to do that part, but I just want to know why the button isn't making it insert all those values into the fields. <?php $dice = rand(1,6); echo "You rolled a<br /><b>{$dice}</b>\n"; $winnings = "500"; if($dice == 6) { include("haha.php"); $cxn = mysqli_connect($dbhost,$dbuser,$dbpassword,$dbdatabase); $username = $cxn->real_escape_string($_SESSION['username']); $sql = "UPDATE `Member` SET `rp` = rp+$winnings WHERE `username` = '$username'"; mysqli_query($cxn,$sql); }?> <FORM ACTION="random.php" METHOD="post"> <INPUT TYPE="submit" VALUE="Roll Again! NAME="sixdice"> </FORM> <?php if (@$_POST['sixdice']) { include("haha.php"); $cxn = mysqli_connect($dbhost,$dbuser,$dbpassword,$dbdatabase); $userid = "$_SESSION['userid']"; $username = "$_SESSION['username']"; $sql = "INSERT INTO Sixdice (userid,username,rolltime) VALUES ('$userid','$username',NOW())"; $result = mysqli_query($cxn,$sql) or die("Query died: insert"); } ?>
  14. You..are..a..GENIUS!!! Awesome. Thanks so much.
  15. That's exactly what I'm already doing. It just won't store.. I am coding the PHP fine and I do have the IPadd field as INT UNSIGNED. Well I don't know what I'm doing wrong now.. I looked at every single tutorial for storing ip addresses and they are all the same and I even copied and pasted their code and it still won't work.
  16. Alright, the register/login system is fully working with sql injection, BUUUT now I want to store their IP Address. WHOLE new function that I've never dealt with before. So I need some help. Am I doing something wrong? I have the IPadd in the database as INT(10) and then I went down to another drop down list and hit unsigned. I feel like I'm doing something wrong with the field in the database.. { $_SERVER['REMOTE_ADDR'] = $IPadd; $sql = "INSERT INTO Member (username,createDate,password,firstName,email,IPadd) VALUES ('$username',NOW(),md5('$password'),'$firstName','$email',inet_aton('$IPadd'))"; mysqli_query($cxn,$sql); $_SESSION['auth']="yes"; $_SESSION['username'] = $username; header("Location: testing.php"); }
  17. Haha I dont care. And cant you see this thing is solved? No reason to post anymore. It was actually because I had 'rp' + $winnings when it should have been rp+$winnings so it was one string. So it wasnt any of your suggestions.. 0.o And I have a book and it says you cant use double quotes inside double quotes. You have to use single quotes and I used double quotes and it gives you an error message so maybe you guys are wrong 0.o Anywhoo, this is solved so just let it die. Jeeezz. xD
  18. I know. I had to stop coding for a month, but Im back now so I still needed to solve this issue...? No reason to get rude.. 0.o People these days... I used double quotes. Trust me. I wouldn't not use someones advice and say it doesn't work without testing it. 0.o
  19. The whole statement is in double quotes so you have to put that in single quotes or it will give you an error.. :|
  20. Ok when I do that, it subtracts it back to 0. When I take those little apostrophes away before and after the plus sign. I gave myself 5000 and when I rolled a six, it set it back down to 0..
  21. I'm not getting any error messages at all. I'm just trying to see what I'm doing wrong to make it only go through the first time you get a six.. The RP was originally at 0 and then jumps up to 500 and then stops no matter if you roll a six again. And it's ok
  22. Changing SET to UPDATE didn't help. Hmmm... I'm super stumped.
  23. Aww thanks for that. (: Buuuuut... it will only add the 500 once now. Here is the code: <?php session_start(); include("logincheck.php"); ?> <?php include_once("header.php"); ?> <td width='100%' valign='top' align='center'> <center><?php $dice = rand(1,6); echo "You rolled a<br /><b>{$dice}</b>\n"; if($dice == 6) { include("haha.php"); $cxn = mysqli_connect($dbhost,$dbuser,$dbpassword,$dbdatabase); $winnings = "500"; $username = $cxn->real_escape_string($_SESSION['username']); $sql = "UPDATE `Member` SET `rp` = 'rp' + '$winnings' WHERE `username` = '$username'"; mysqli_query($cxn,$sql); } ?></center> </td></p> <?php include_once("footer.php"); ?> Anyone know why it only adds once and then stops even if i roll another 6?
  24. EDIT I got it fixed. Nevermind. Gosh I'm so glad!! I'll fix that later. (: Thanks for the suggestion. Here is how my code looks and it's not giving me any errors, but it won't update: <?php include("logincheck.php"); ?> <?php include_once("header.php"); ?> <td width='100%' valign='top' align='center'> <?php $dice = rand(1,6); echo "You rolled a<br /><b>{$dice}</b>\n"; if($dice == 6) { include("haha.php"); $cxn = mysqli_connect($dbhost,$dbuser,$dbpassword,$dbdatabase); $winnings = "500"; $username = $cxn->real_escape_string($_SESSION['username']); $sql = "UPDATE `Member` SET `rp` = 'rp + $winnings' WHERE `username` = '$username'"; mysqli_query($cxn,$sql); } ?> </td></p> <?php include_once("footer.php"); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.