Jump to content

sarmenhb

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

sarmenhb's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. yea i know lol, i am going to do that later.
  2. lol my problem was here $checkuser= mysql_query("select username from users where username = '$checkuser'") or die(mysql_error()); thanks all lol cant believe i didnt see it.
  3. here is the new updated code, i have also included the table structure <?php include("conn.php"); mysql_select_db("lms") or die(mysql_error()); #=========================================================== # check if username/password has been entered #=========================================================== if(isset($_POST['login'])) { if(!$_POST['username'] || !$_POST['password']) { die('enter both fields'); } #=========================================================== # check if the table contains anything #=========================================================== $checkdata = mysql_query("select * from users") or die(mysql_error()); if(mysql_num_rows($checkdata) <= 0) { die('no data exists in the database, you need to add a user <a href="admin.php">click here</a>'); } #=========================================================== # check if user exists in the database #=========================================================== $username = $_POST['username']; $checkuser= mysql_query("select username from users where username = '$checkexist'") or die(mysql_error()); if(mysql_num_rows($checkuser) == 0) { die('that username doesnt exist in our database'); } else{ #=================== $password = md5($_POST['password']); $query = mysql_query("select password from users"); while($row = mysql_fetch_array($query)) { #=========================================================== # check if password matches the username #=========================================================== if ( md5($_POST['password']) != $row['password'] ) { } else { echo "<script>alert('your in');</script>"; } } } } else { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" > <p>Username: </p> <p><input type="text" name="username" /> <br /> <br /> </p> <p>Password: </p> <p><input type="password" name="password" /> <br /> <br /> <input type="submit" value=" login " name="login" /> </p> </form> </body> </html> <?php } ?> table structure and its data CREATE TABLE `users` ( `id` int, `fname` varchar(20) CHARACTER SET `latin1` COLLATE `latin1_swedish_ci`, `lname` varchar(20) CHARACTER SET `latin1` COLLATE `latin1_swedish_ci`, `username` varchar(20) CHARACTER SET `latin1` COLLATE `latin1_swedish_ci`, `password` varchar(50) CHARACTER SET `latin1` COLLATE `latin1_swedish_ci`, `level` varchar(10) CHARACTER SET `latin1` COLLATE `latin1_swedish_ci` ); INSERT INTO `users` (`id`, `fname`, `lname`, `username`, `password`, `level`) VALUES (12, 'myname', 'mylastname', 'sarmenhb', '79ef12f7caa49f3c95499143dc9daf68', 'student'); COMMIT; this is the alert im receiving. the username doesnt exist in our database
  4. anyone else know? i cant spot it ((( ??? ??? ??? ???
  5. the password is md5'ed in the table.
  6. <?php include("conn.php"); mysql_select_db("lms") or die(mysql_error()); #=========================================================== # check if username/password has been entered #=========================================================== if(isset($_POST['login'])) { if(!$_POST['username'] || !$_POST['password']) { die('enter both fields'); } #=========================================================== # check if user exists in the database #=========================================================== $username = $_POST['username']; $checkexist = mysql_query("select username from users where username = '$checkexist'") or die(mysql_error()); if(mysql_num_rows($checkexist) == TRUE) { die('that username doesnt exist in our database'); } #=========================================================== # check if the table contains anything #=========================================================== $checkdata = mysql_query("select * from users") or die(mysql_error()); if(mysql_num_rows($checkdata) <= 0) { die('no data exists in the database, you need to add a user <a href=\"admin.php\">click here</a>'); } #=================== $password = md5($_POST['password']); $query = mysql_query("select * from users"); while($row = mysql_fetch_array($query)) { #=========================================================== # check if password matches the username #=========================================================== if ($row['password'] != md5($_POST['password'])) { die('the password that was entered is incorrect'); } else { echo "<script>alert('your in');</script>"; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <p>Username: </p> <p><input type="text" name="username" /></p> <br /> <br /> <p>Password: </p> <p><input type="password" name="password" /></p> <br /> <br /> <input type="submit" value=" login " name="login" /> </form> </body> </html> <?PHP } ?>
  7. what im trying to do is, i have a drop down that displays all the files that are in the directory when the page loads. when a item is selected from the drop down list i want that file to load in the text area but i cannot get it to work, can someone tell me what im doing wrong? thanks, appreciate it. ============================== <? $path = "c:\\code\\"; $dir = opendir($path); ?> <form method="post" type=" <? $_SERVER['PHP_SELF'] ?>"> <label> <select name="select" id="select"> <? while ($listing = readdir($dir)) { echo "<option value='".$listing."'".$listing."'>".$listing."</option>"; } fclose($listing); $file = fopen($listing, "a+"); $size = filesize($fn); $text = fread($file, $size); fclose($file); ?> </select> </label> <br><br><br><br><br> <textarea name="name" cols="100" rows="10"><? echo $text; ?></textarea> <input type="submit" value="submit"/> </form>
×
×
  • 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.