premiso Posted December 23, 2009 Share Posted December 23, 2009 Try saving the file using Notepad and not Notepad++ and see what happens. If it works your notepad++ is doing something funky to files when saving and I would suggest re-installing it. Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/page/2/#findComment-983159 Share on other sites More sharing options...
zero_ZX Posted December 25, 2009 Author Share Posted December 25, 2009 Wow thanks m8! Working flawlessly with new editor I have a problem when logging in.. Basicly, i want to select & store/save the member if from the members table where name = username from form. To do this i have: // Create query $id = "SELECT member_id FROM `members` " ."WHERE `name`='".$_POST["username"]."' "; Now i want to check if username + password is correct, and their account is not locked. I start to check if the username is valid (once again), then check if they are locked, and then check the password where the member id = the one we found earlier. To do this: // Create query $id = "SELECT member_id FROM `members` " ."WHERE `name`='".$_POST["username"]."' "; $q = "SELECT * FROM `members` " ."WHERE `name`='".$_POST["username"]."' " ."AND `p_locked`=0 " ."AND SELECT field_13 FROM `pfields_content` " ."WHERE `id`='".$id."' " ."AND WHERE `field_13`=('".$_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: shop.php"); } else { // Login not successful die("Sorry, could not log you in. Wrong login information. <br> Or your fg has been locked. Please contact Smilie."); } } Full code:: <?php session_start(); // dBase file include 'inc/config.php'; if ($_GET["op"] == "login") { if (!$_POST["username"] || !$_POST["password"]) { die("You need to provide a username and FG-Pass."); } // Create query $id = "SELECT member_id FROM `members` " ."WHERE `name`='".$_POST["username"]."' "; $q = "SELECT * FROM `members` " ."WHERE `name`='".$_POST["username"]."' " ."AND `p_locked`=0 " ."AND SELECT field_13 FROM `pfields_content` " ."WHERE `id`='".$id."' " ."AND WHERE `field_13`=('".$_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: shop.php"); } else { // Login not successful die("Sorry, could not log you in. Wrong login information. <br> Or your fg has been locked. Please contact Smilie."); } } else { //If all went right the Web form appears and users can log in echo "<form action=\"?op=login\" method=\"POST\">"; echo "Username: <input name=\"username\" size=\"15\"><br />"; echo "FG-Password: <input type=\"password\" name=\"password\" size=\"8\"><br />"; echo "<input type=\"submit\" value=\"Login\">"; echo "</form>"; } ?> Error when trying to login: Username/password wrong.. No php error. Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/page/2/#findComment-983993 Share on other sites More sharing options...
zero_ZX Posted December 25, 2009 Author Share Posted December 25, 2009 A kindly Bump Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/page/2/#findComment-984027 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.