Search the Community
Showing results for tags 'password form encryption'.
-
Hi, I recently just created a test site to see what I can produce and everything is working fine apart from the login form. Here's the code I have. <?php session_start(); // dBase file include "dbConfig.php"; if ($_GET["op"] == "fail") { echo "<ul><li><h1 class='FailLoginState'>You need to be logged in to access the members area!</h1></li></ul>"; } if ($_GET["op"] == "login") { if (!$_POST["username"] || !$_POST["password"]) { die("You need to provide a username and password."); } // Create query $q = "SELECT * FROM `TABLENAMEHERE` " ."WHERE `username`='".$_POST["username"]."' " ."AND `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"]; $_SESSION["valid_time"] = time(); // Redirect to member page Header("Location: members.php"); } else { // Login not successful echo '<form action="?op=login" method="POST">'; echo 'Username:<br><input class="InputForm" type="text" name="username" id="username"><br>'; echo '<br>'; echo 'Password:<br><input class="InputForm" type="password" name="password" id="password"><br>'; echo '<br>'; echo '<button type="submit" name="submit" class="InputButton" value="Login">Submit</button>'; echo '</form>'; echo '<ul><li></li></ul>'; echo("<h1 class='FailLoginState'>Sorry, couldn't log you in. Wrong login information.</h1>"); } } else { echo '<form action="?op=login" method="POST">'; echo 'Username:<br><input class="InputForm" type="text" name="username" id="username"><br>'; echo '<br>'; echo 'Password:<br><input class="InputForm" type="password" name="password" id="password"><br>'; echo '<br>'; echo '<button type="submit" name="submit" class="InputButton" value="Login">Submit</button>'; echo '</form>'; } ?> If they're any bugs or something that looks weird in there it's because I'm new to PHP The problem mainly is when the client trys to log in after registering they can't because when they register it encrypts their password with MD5 encryption so when they go to log in, it comes up with the "Incorrect information" error. How do I make it so that it reads that password from the database? Thanks.