Jump to content

Chidori Soul

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Chidori Soul's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Well, from my experience using it, it enters the user, then reruns the script and says that the username is taken.
  2. Well, in my way, you do this. $query = mysql_query("SELECT * FROM `users` WHERE `user_id`='$user'"); $result = mysql_fetch_array($query); if($_GET['points'] == 'increase') { //increase the count. $update = $result['count'] + 1; } elseif($_GET['points'] == 'decrease') { //decrease the count. $update = $result['count'] - 1; } $update = mysql_query("UPDATE `users` SET `count`='$update' WHERE `user_id`='$user'");
  3. I would recommend reducing your double-query + PHP processing to a single query: $update = mysql_query("UPDATE users SET count = count+1 WHERE user_id='$user'"); And, for God's sake, never use a SELECT * if you're not going to work with ALL the columns. It's inefficient. I know, I was just trying to provide an alternate solution to his problem, sometimes the longer ways function a bit better.
  4. Well, I'm not sure if this will help, but to what I normally do, your update query for setting the count is missing something. I'm not sure if your way works or not, but try this. $query = mysql_query("SELECT * FROM `users` WHERE `user_id`='$user'"); $result = mysql_fetch_array($query); $count = $result['count'] + 1; //If its decreasing, replace it with minus, etc $update = mysql_query("UPDATE `users` SET `count`='$count' WHERE `user_id`='$user'"); Same with you checking count from the users table, you could do it a different way. $query1 = mysql_query("SELECT * FROM `users` WHERE `user_id`='$user'"); $result1 = mysql_fetch_array($query1); $points = $result1['count']; echo "This user has ".$count." points."; //etc I'm not exactly sure if this will help, but its the best I can think of.
  5. <?php session_start(); require('require/connect.php'); require('require/clean_code.php'); $name = safe($_GET['user']); if(isset($_GET['user'])) { $pass = safe($_GET['pass']); $email = safe($_GET['email']); $gender = safe($_GET['gender']); $class = safe($_GET['type']); if($name=='') { echo "Please enter a name."; } elseif($pass=='') { echo "Please enter a password."; } elseif($email=='') { echo "Please enter an email."; } elseif($gender != "Male" && $gender != "Female") { echo "Please choose a legit gender."; } elseif($class != "Warrior" && $class != "Mage") { echo "Please choose a legit class."; } else { $q = mysql_query("SELECT * FROM `users` WHERE `name`='".$name."'"); $c = mysql_num_rows($q); $q1 = mysql_query("SELECT * FROM `users` WHERE `email`='".$email."'"); $c1 = mysql_num_rows($q1); if($c > 0) { echo "This name is already in use."; } elseif($c1 > 0) { echo "This email is already in use."; } else { $pass2 = sha1($pass); mysql_query("INSERT INTO `users` (`name`, `pass`, `email`, `type`, `gender`) VALUES ('".$name."', '".$pass2."', '".$email."', '".$class."', '".$gender."')") or die(mysql_error()); echo "You have successfuly registered, ".$name."."; } } } else { ?> <head> <script type='text/javascript' src='require/jquery.js'></script> <script type='text/javascript' src='require/main.js'></script> <script type='text/javascript'> function function1() { var user = window.document.reg.user.value; var pass = window.document.reg.password.value; var email = window.document.reg.email.value; var gender = window.document.reg.gender.value; var class = window.document.reg.class.value; var url = "reg.php?user=" + user + "&pass=" + pass + "&email=" + email + "&gender=" + gender + "&type=" + class + ""; loadlink(url); } </script> </head> TestRegister <form name='reg' onsubmit='return function1();'> <table width='98%' style='border: 1px solid black;' valign='top' align='center'> <tr><td width='30%' style='border: 1px solid black;'>Username</td><td width='70%' style='border: 1px solid black;'><input type="text" name="user"></td></tr> <tr><td width='30%' style='border: 1px solid black;'>Password</td><td width='70%' style='border: 1px solid black;'><input type="password" name="password"></td></tr> <tr><td width='30%' style='border: 1px solid black;'>Email</td><td width='70%' style='border: 1px solid black;'><input type="text" name="email"></td></tr> <tr><td width='30%' style='border: 1px solid black;'>Gender</td><td width='70%' style='border: 1px solid black;'><select name="gender"><option value="Male">Male</option><option value="Female">Female</option></select></td></tr> <tr><td width='30%' style='border: 1px solid black;'>Class</td><td width='70%' style='border: 1px solid black;'><select name="class"><option value="Warrior">Path Of Swordsmen</option><option value="Mage">Guidance Of Magician</option></select></td></tr> <tr><td width='30%' colspan='2' style='border: 1px solid black;'><input type='submit' name='submit' value='Register!' onclick='function1();'></td></tr> </table> </form> <?php } ?> I did that, and still, the same result, I think it has something to do with my AJAX.
  6. Alright, so I'm doing a pure dynamic AJAX site, and i've been on a register script for 2 days now, and for some reason, something about it makes it weird. <?php session_start(); require('require/connect.php'); require('require/clean_code.php'); $name = safe($_GET['user']); if(isset($_GET['user'])) { $pass = safe($_GET['pass']); $email = safe($_GET['email']); $gender = safe($_GET['gender']); $class = safe($_GET['type']); if($name=='') { echo "Please enter a name."; } elseif($pass=='') { echo "Please enter a password."; } elseif($email=='') { echo "Please enter an email."; } elseif($gender != "Male" && $gender != "Female") { echo "Please choose a legit gender."; } elseif($class != "Warrior" && $class != "Mage") { echo "Please choose a legit class."; } else { $q = mysql_query("SELECT * FROM `users` WHERE `name`='".$name."'"); $c = mysql_num_rows($q); $q1 = mysql_query("SELECT * FROM `users` WHERE `email`='".$email."'"); $c2 = mysql_num_rows($q1); if($c > '0') { echo "This name is already in use."; } elseif($c1 > '0') { echo "This email is already in use."; } else { $pass2 = sha1($pass); mysql_query("INSERT INTO `users` (`name`, `pass`, `email`, `type`, `gender`) VALUES ('".$name."', '".$pass2."', '".$email."', '".$class."', '".$gender."')") or die(mysql_error()); echo "You have successfuly registered, ".$name."."; } } } else { ?> <head> <script type='text/javascript' src='require/jquery.js'></script> <script type='text/javascript' src='require/main.js'></script> <script type='text/javascript'> function function1() { var user = window.document.reg.user.value; var pass = window.document.reg.password.value; var email = window.document.reg.email.value; var gender = window.document.reg.gender.value; var class = window.document.reg.class.value; var url = "reg.php?user=" + user + "&pass=" + pass + "&email=" + email + "&gender=" + gender + "&type=" + class + ""; loadlink(url); } </script> </head> TestRegister <form name='reg' onsubmit='return function1();'> <table width='98%' style='border: 1px solid black;' valign='top' align='center'> <tr><td width='30%' style='border: 1px solid black;'>Username</td><td width='70%' style='border: 1px solid black;'><input type="text" name="user"></td></tr> <tr><td width='30%' style='border: 1px solid black;'>Password</td><td width='70%' style='border: 1px solid black;'><input type="password" name="password"></td></tr> <tr><td width='30%' style='border: 1px solid black;'>Email</td><td width='70%' style='border: 1px solid black;'><input type="text" name="email"></td></tr> <tr><td width='30%' style='border: 1px solid black;'>Gender</td><td width='70%' style='border: 1px solid black;'><select name="gender"><option value="Male">Male</option><option value="Female">Female</option></select></td></tr> <tr><td width='30%' style='border: 1px solid black;'>Class</td><td width='70%' style='border: 1px solid black;'><select name="class"><option value="Warrior">Path Of Swordsmen</option><option value="Mage">Guidance Of Magician</option></select></td></tr> <tr><td width='30%' colspan='2' style='border: 1px solid black;'><input type='submit' name='submit' value='Register!' onclick='function1();'></td></tr> </table> </form> <?php } ?> If you tried this, it would be successful, but it would say that the username is already registered, so it really lies. Can someone point out the error on this AJAX/PHP?
  7. That is the code that I use for my register page I already did, there should be nothing wrong with it
  8. I still don't get what is up with my code, it should work perfectly, I have checked everything, and it should work >_>
  9. Yes, passwords are encrypted in my database, but what does sha1 have to do with this?
  10. Hey, I am making a Login code, and everything is complete, but it is not working properly. The error is this: Even though I enter everything correctly, it always says that the password is incorrect? My code is this: <?php session_start(); require_once 'db.php'; $page_mode = isset($_POST['page_mode']) ? $_POST['page_mode'] : ''; $error_string = ''; if ($page_mode == 'login') { $name = $_POST['name']; $password = $_POST['password']; if (trim($name) == '' || trim($password) == '') $error_string .= 'Please enter your username and password.<br>'; else { $result = db_query("SELECT id, name, password FROM users WHERE name='" . mysql_real_escape_string($name) . "'"); if (!($row = mysql_fetch_assoc($result))) $error_string .= 'The username was not found.<br>'; else if ($row['password'] != sha1($password)) $error_string .= 'The password does not match the username provided.<br>'; else { $_SESSION['user_id'] = $row['id']; $_SESSION['user_name'] = $row['name']; header('Location: index.php'); exit(); } } } ?> <html><center> <head> <title>Pokemon Planet - Version 0.1</title> <link rel='stylesheet' type='text/css' href='stylesheet.css'> <body><div class="error_text"><?php echo $error_string; ?></div> <div id="container"> <div id="banner"></div> <div id="frame"> <div id="leftmenu"><div style="padding: 3px;"> <center><b>General Options</b><br/><a href='index.php'>Index</a><br/><a href='register.php'>Register</a><br/><a href='login.php'>Login</a></center> </div></div> <div id="content"><div style="padding: 3px;"> <center><u>Login!</u><br/>Here you can login to access the RPG, but you have to have already <a href='register.php'>registered</a>.<br/><br/><form action="login.php" method="post"><input type="hidden" name="page_mode" value="login"><b>Username:</b><br/><input type="text" name="name" size="20" maxlength="255" value="<?php if (isset($name)) echo $name; ?>"><br/><br/><b>Password:</b><br/><input type="password" name="password" size="20"><br/><input type="submit" value="Log In" size="30"></center> </div></div> <div id="rightmenu"><div style="padding: 3px;"> <center><b>General Options</b><br/><a href='index.php'>Index</a><br/><a href='register.php'>Register</a><br/><a href='login.php'>Login</a></center> </div></div> </div> <div id="footer"><center><font color='#000000'>Pokemon Planet is © 2009 by Shadow. This site is created and coded by Shadow. Pokemon Planet is in no way affiliated with Nintendo, Pokémon Company, Game Freak, Creatures, or any related organizations. Most Pokémon images (sprites, icons, map tiles, etc.) are © Nintendo and their publishers. Images are slightly modified in order to meet certain needs upon this website.</font></center></div> </div></body></center> </html>
  11. Oh, Thanks! Now, I just need to know on how to make one page for each user, and have it add another ID for each user registered like this: profile.php?id=1 now, if ID 2 registers, they could click View Profile, and it would be: profile.php?id=2, and if ID 3 clicks it...etc Would this have to do with Cookies or Sessions?
  12. Axeia: I did look through that and the Source Code, and I did not find those errors in my original code. DarKsuperHero: I know, someone says that it is based on this statement: if (isset($_POST['submit'])) { but, I can not find where I would replace it for the CSS to come back and work
  13. haku: I am reading through a book about it right now, and that, but I can't seem to find the information I am looking for Ken2k7: I have the table set up, I just need to know how to read it then display the information gathered from the table.
  14. Ok, I am trying to make a User Profile, and I heard that you could just create one page, that shows what you need with reading the Table based on each user. Now, I just need to figure out how to do that, please help
×
×
  • 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.