Jump to content

rainprop

Members
  • Posts

    27
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

rainprop's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. this is code.pls help..the previous one is wrong.. login2.php <?php session_start(); require_once 'database.php'; $username = $_POST['username']; $md5_password = md5($_POST['password']); $query = mysql_query("select * from user where username = '$username' and password = '$md5_password'"); if(mysql_num_rows($query) > 0) { $result = mysql_fetch_assoc($query); $_SESSION['username'] = $_POST['username']; header("location:index.php"); } else{ echo "Wrong Username or Password"; } ?> <form name="back" method="post" action="login.php"> <input type="submit" name="back" id="back" value="Back to Home"> index.php <?php session_start(); require_once 'database.php'; if (isset($_SESSION['username'])){ echo "Welcome ".$_SESSION['username']; ?> <form name="logout" method="post" action="logout.php"> <input type="submit" name="logout" id="logout" value="Logout"> </form> <br /><form name="news" method="post" action="news.php"> <input type="submit" name="news" id="news" value="News"> </form> <?php } elseif(isset($_SESSION['admin'])){ echo"Welcome ".$_SESSION['admin']; echo"<br><br>You are logged in as an Admin"; ?> <form name="logout" method="post" action="logout.php"> <input type="submit" name="logout" id="logout" value="Logout"> </form> <?php } ?> login.php <form name="login_form" method="post" action="login2.php"> <label> <input name="username" type="text" id="username">Username<br /> <input name="password" type="password" id="password">Password<br /> </label> <input type="submit" name="login" id="login" value="Login"> </label> </p>
  2. yup, i have already made the connection... login2.php <?php session_start(); require_once 'database.php'; $username = $_POST['username']; $md5_password = md5($_POST['password']); $query = mysql_query("select * from user where username = '$username' and password = '$md5_password'"); if(mysql_num_rows($query) > 0) { $result = mysql_fetch_assoc($query); $_SESSION['username'] = $_POST['username']; header("location:index.php"); } else{ echo "Wrong Username or Password"; } ?> <form name="back" method="post" action="login.php"> <input type="submit" name="back" id="back" value="Back to Home"> index.php <?php session_start(); require_once 'database.php'; if (isset($_SESSION['username'])){ echo "Welcome ".$_SESSION['username']; ?> <form name="logout" method="post" action="logout.php"> <input type="submit" name="logout" id="logout" value="Logout"> </form> <br /><form name="news" method="post" action="news.php"> <input type="submit" name="news" id="news" value="News"> </form> <?php } elseif(isset($_SESSION['admin'])){ echo"Welcome ".$_SESSION['admin']; echo"<br><br>You are logged in as an Admin"; ?> <form name="logout" method="post" action="logout.php"> <input type="submit" name="logout" id="logout" value="Logout"> </form> <?php }else{ ?> <form name="login_form" method="post" action="login2.php"> <label> <input name="user" type="text" id="user">ID<br /> <input name="pass" type="password" id="pass">Password<br /> </label> <input type="submit" name="login" id="login" value="Login"> </label> </p> <?php } ?>
  3. it only created more errors.. Notice: Undefined index: username in C:\wamp\www\login2.php on line 17 Notice: Undefined index: password in C:\wamp\www\login2.php on line 19 Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\login2.php on line 23 Wrong Username or Password
  4. Hi... Im creating a simple login page, and i got a parse error..may i know how to fix it?? $username = $_POST['username']; # make a md5 password. $md5_password = md5($_POST['password']); $query = mysql_query("select * from user where username = "$username" and password = "$md5_password""); thank u to whoever replies...
  5. 1.THE SO CALLED ERROR.. as i've put it that way.. this is wat it comes when i try to login.. Sorry, could not log you in. Wrong login information. 2. Id username password emp_num 1 123 123 1 the datas which i've inserted earlier r just for trial purposes, to make sure it runs,..
  6. yes i duno...pls tell me how...
  7. this is full coding for my login.php page, prior to that i have configuration.php too. <?php session_start(); // dBase file include "dbConfig.php"; if (isset($_GET['op']) && $_GET["op"] == "login") { if (!$_POST["username"] || !$_POST["password"]) { die("You need to provide a username and password."); } $q = "SELECT * FROM `user` " ."WHERE `username`='".$_POST["username"]."' " ."AND `password`=SHA1('".$_POST["password"]."') " ."LIMIT 1"; // Run query $r = mysql_query($q); if ( $obj = @mysql_fetch_object($r) ) { // Login good, create session variables $_SESSION["valid_username"] = $obj->username; $_SESSION["valid_password"] = $_POST["password"]; Header("Location: members.php"); } else { die("Sorry, could not log you in. Wrong login information."); } } else { echo "<form action=\"?op=login\" method=\"POST\">"; echo "Username: <input name=\"username\" size=\"15\"><br />"; echo "Password: <input type=\"password\" name=\"password\" size=\"8\"><br />"; echo "<input type=\"submit\" value=\"Login\">"; echo "</form>"; } ?> the config.php is / $host = "localhost"; $user = "root"; $db = "payroll4; // Then you need to make sure the database you want // is selected. mysql_select_db($payroll4); ?> pls help me.....thanks..
  8. its still the same...im so sad... duno whr the mistake is...rely duno.. it says that it cant login, bcoz of wrong username and pasword..
  9. i've tried, but it cant produce any results in mysql.it says error in syntax.. how now?? :'(
  10. hi, wat does this mean?how to solve it?? data retrieval error: unknown column 'department.DEP_RATE' in 'field list' thanks..
  11. im sorry but im kinda new to this php thing.. echoing the query means?? is it copy the query at mysql console and see whats the result? anyway i did my database in phpmyadmin..
  12. i've tried 5 different ways to create a login page... but all give the same results.. WRONG ID AND PASSWORD. this is the latest login page which i've created..im starting to think that something may be wrong with my database itself..but im still lost.. my database has a table called user the attributes in it are Id , username, password, and emp_num can anyone please help..a million thanks in advance. // Create query $q = "SELECT * FROM `user` " ."WHERE `username`='".$_POST["username"]."' " ."AND `password`=PASSWORD('".$_POST["password"]."') " ."LIMIT 1"; // Run query $r = mysql_query($q); if ( $obj = @mysql_fetch_object($r) ) { // Login good, create session variables $_SESSION["valid_Id"] = $obj->Id; $_SESSION["valid_user"] = $_POST["username"]; // Redirect to member page Header("Location: members.php"); } else { // Login not successful die("Sorry, could not log you in. Wrong login information."); } } else
  13. this is my code..can someone tell me wats wrong in that line?? if ($_GET["op"] == "login") { if (!$_POST["username"] || !$_POST["password"]) { die("You need to provide a username and password."); }
×
×
  • 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.