Jump to content

e4games

Members
  • Content Count

    102
  • Joined

  • Last visited

Community Reputation

0 Neutral

About e4games

  • Rank
    Member
  1. e4games

    User List Error

    Thanks, it works know
  2. e4games

    User List Error

    my revised code is on the first post...I editted it..like I said in my post.
  3. e4games

    User List Error

    I changed the code at the top...and it still gets the same error D: I also tried it with the semicolons only after the lines with the curly braces it them, but it still gets the same errorAnd it says no where that you need to put curly braces around PHP with HTML with it, especially not at the beginning of anything
  4. e4games

    User List Error

    I can't find a error with this code...can you guys help me? <?phpmysql_connect("Host Name", "username", "pass") or die(mysql_error()); mysql_select_db("DB name") or die(mysql_error()); $query=mysql_query ("SELECT * FROM users");echo "<tr><td colspan='2' bgcolor='darkyellow'>.::. Users .::.</td><tr/><tr><td colspan='2'>";while "($row = mysql_query ($query) ) ";{echo "<tr><td> {$row['ID']}";echo "</td></tr>";echo "<tr><td> {$row['username']}";echo "</td></tr>";}echo "</table>"";?> The code is supposed to output a users ID and name inside of a table...but a white screen just happens D:
  5. e4games

    Fan Site

    Don't bother even posting if your not going to say anything to make it better. EX- "The design was a bit ugly." then what would you recommend for colors.
  6. e4games

    Fan Site

    I made a fan site of pokemon, Its only about 5 days old and I was wondering if u guys think if its horrible or at least ok....My Pokemon Fansite
  7. e4games

    Error

    I tried changing it to what you said phpnoob, still doesn't work...I also added a error string, and there is still only a blank screen...
  8. e4games

    Error

    Oh o.O, well I fixed it and it still doesn't work...and its called Users..
  9. e4games

    Error

    I've looked threw the database and there was only 1 table called users, anyways I changed a few other things and it seems to work (didn't even touch the database)Anyways I still don't know what to do with the login issue, I'm gonna post it in the first post becuase I don't think its the way I'm coding the link to get to it, I think it might be the code for the login.... (cause I've have problems with this happening and it was the login code not the hyperlink code)
  10. e4games

    Error

    But I do have a table called "users"........I just checked the login and for some reason when you press the "login" button, the URL doesn't do anything, but I did it the same way that I did it with the register, and that works...
  11. e4games

    Error

    So...I tryed a different code for register and it still gets a error....help please! <?phpmysql_connect("MYSQL hostname", "username", "pass") or die(mysql_error()); mysql_select_db("database name") or die(mysql_error()); //Checks if there is a login cookieif(isset($_COOKIE['user']))//if there is, it logs you in and directes you to the members page{ $username = $_COOKIE['user']; $pass = $_COOKIE['Key_my_site'];$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());while($info = mysql_fetch_array( $check )) {if ($pass != $info['password']) {}else{header("Location: members.php");}}}//if the login form is submittedif (isset($_POST['submit'])) { // if form has been submitted// makes sure they filled it inif(!$_POST['username'] | !$_POST['pass']) {die('You did not fill in a required field.');}// checks it against the databaseif (!get_magic_quotes_gpc()) {$_POST['email'] = addslashes($_POST['email']);}$check = mysql_query("SELECT * FROM Users WHERE username = '".$_POST['username']."'")or die(mysql_error());//Gives error if user dosen't exist$check2 = mysql_num_rows($check);if ($check2 == 0) {die('That user does not exist in our database. <a href=register.php>Click Here to Register</a>');}while($info = mysql_fetch_array( $check )) {$_POST['pass'] = stripslashes($_POST['pass']);$info['password'] = stripslashes($info['password']);$_POST['pass'] = $_POST['pass'];//gives error if the password is wrongif ($_POST['pass'] != $info['password']) {die('Incorrect password, please try again.');}else { // if login is ok then we add a cookie $_POST['username'] = stripslashes($_POST['username']); $hour = time() + 3600; setcookie(user, $_POST['username'], $hour); setcookie(Key_my_site, $_POST['pass'], $hour); //then redirect them to the members area header("Location: members.php"); } } } else { // if they are not logged in ?> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> Username: <input type="text" name="username" maxlength="20"><br>Password: <input type="password" name="pass" maxlength="25"> <br><input type="submit" name="submit" value="Login"> </form> <?php I'm currently getting a blank screen for itJust in case it's the link code I post it to <a href="login.php">Login</a>
  12. e4games

    Custom Things

    So I know if you set (when they register) is you do something like $username, it will display the viewing persons username. But how do I make it so that it only displays one username. Like when someone posts something for it to display that username to everyone. Or do it like a avatar when u pick a avatar to make sure that it only displays that users avatar not who ever is viewing it.
  13. e4games

    Login Error

    Ok, so know when you register it submits the information into the database, but instead of putting it in what you typed it puts in random characters. If you go to login using the random characters that it set as your password it still doesn't let you login. Here are my register and login codes. <?php require_once 'db.php'; $page_mode = $_POST['page_mode']; # empty variable defaults to '' (or null) if ($page_mode === 'register') { $username = mysql_real_escape_string(trim($_POST['username'])); $password = $_POST['password']; if ($password !== $_POST['conf_password']) $error_string .= 'Password mismatch.<br>'; if ($error_string == '') { $result = db_query("SELECT username FROM users WHERE username='$username';"); if (mysql_num_rows($result) > 0) $error_string .= 'The username is already registered.<br>'; else { $password = sha1($password); // hash password once db_query("INSERT INTO users (username, password) VALUES ('$username', '$password');"); header('Location: thankyou.php'); exit(); } } } ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html> <head> <title>Register</title> <style type="text/css"> .error_text { color: #FF0000; width: 400px; text-align: center; } .left_box { float: left; width: 150px; text-align: right; padding-right: 5px; } .right_box { clear: right; } </style> </head> <body> <div class="error_text"><?php echo $error_string; ?></div> <form action="register.php" method="post"> <input type="hidden" name="page_mode" value="register"> <div class="left_box">Username</div> <div class="right_box"><input type="text" name="username" size="30" maxlength="255" value="<?php if (isset($username)) echo $username; ?>"></div> <div class="left_box">Password</div> <div class="right_box"><input type="password" name="password" size="30"></div> <div class="left_box">Confirm Password</div> <div class="right_box"><input type="password" name="conf_password" size="30"></div> <div class="left_box"> </div> <div class="right_box"><input type="submit" value="Register" size="30"></div> </form> </body></html> Login Code <?php session_start(); $error_string = ''; # error_string is modified in db.php! require_once 'db.php'; $page_mode = $_POST['page_mode']; # empty variable defaults to '' (or null) if ($page_mode === 'login') { $username = mysql_real_escape_string(trim($_POST['username'])); $password = $_POST['password']; if ($username == '' || strlen($password) == 0) # password can be of spaces, which must not be trimmed! $error_string .= 'Please enter your username and password.<br>'; else { $result = db_query("SELECT id, username, password FROM users WHERE username='$username';"); if (!($row = mysql_fetch_assoc($result))) $error_string .= 'The username was not found.<br>'; else if ($row['password'] != sha1($password)) $error_string .= 'The password did not match.<br>'; else { $_SESSION['user_id'] = $row['id']; $_SESSION['user_name'] = $row['username']; header('Location: /'); exit(); } } } ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html> <head> <title>Register</title> <style type="text/css"> .error_text { color: #FF0000; width: 400px; text-align: center; } .left_box { float: left; width: 150px; text-align: right; padding-right: 5px; } .right_box { clear: right; } </style> </head> <body> <div class="error_text"><?php echo $error_string; ?></div> <form action="login.php" method="post"> <input type="hidden" name="page_mode" value="login"> <div class="left_box">Username</div> <div class="right_box"><input type="text" name="username" size="30" maxlength="255" value="<?php if (isset($username)) echo $username; ?>"></div> <div class="left_box">Password</div> <div class="right_box"><input type="password" name="password" size="30"></div> <div class="left_box"> </div> <div class="right_box"><input type="submit" value="Log In" size="30"></div> </form> </body></html>
  14. e4games

    Db.php File

    <?phprequire_once 'db.php';$page_mode = isset($_POST['page_mode']) ? $_POST['page_mode'] : '';$error_string = '';if ($page_mode == 'register'){ $username = trim($_POST['username']); // trim to remove whitespace $password = $_POST['password']; $conf_password = $_POST['conf_password']; if ($error_string == '') { $result = db_query("SELECT id FROM users WHERE username='" . mysql_real_escape_string($username) . "'"); if (mysql_num_rows($result) > 0) $error_string .= 'That username is already registerd.<br>'; else { $username = mysql_real_escape_string($username); // protect against SQL attacks $password = sha1($password); // hash password db_query("INSERT INTO users (username, password) VALUES ('{$username}', '.sha1{$password}')"); header('Location: thankyou.php'); exit(); } }}?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html> <head> <title>Register</title> <style type="text/css"> .error_text { color: #FF0000; width: 400px; text-align: center; } .left_box { float: left; width: 150px; text-align: right; padding-right: 5px; } .right_box { clear: right; } </style> </head> <body> <div class="error_text"><?php echo $error_string; ?></div> <form action="register.php" method="post"> <input type="hidden" name="page_mode" value="register"> <div class="left_box">Username</div> <div class="right_box"><input type="text" name="username" size="30" maxlength="255" value="<?php if (isset($username)) echo $username; ?>"></div> <div class="left_box">Password</div> <div class="right_box"><input type="password" name="password" size="30"></div> <div class="left_box">Confirm Password</div> <div class="right_box"><input type="password" name="conf_password" size="30"></div> <div class="left_box"> </div> <div class="right_box"><input type="submit" value="Register" size="30"></div> </form> </body></html>
  15. e4games

    Db.php File

    <?php$con = mysql_connect('FTP_Hostname', 'username', 'password');mysql_select_db('Database_Name',);function db_query($sql){ return mysql_query($sql, $GLOBALS['con']);}?>
×
×
  • Create New...