Matching Password With One Already In Database
I am using PHP5 I have written the code to insert a password into the data base for a registrtion form.When I am trying to to match using a log in form so I can continue to the next page I keep getting the error message Username and password are not the same as those on file. Here is my code for inseting into database:
//Make the Query
$query = "INSERT INTO registration (first_name, last_name, email, user_name, password)
VALUES('$fn', '$ln', '$e', '$un', PASSWORD('$p'))";
$result = @mysql_query($query); // Run the query.
Here is my code for retrieving it
$query = "SELECT user_id, first_name FROM registration WHERE user_name1 ='$un' AND password1=PASSWORD('$p')";
$result = @mysql_query ($query);
$row = mysql_fetch_array ($result, MYSQL_NUM);
Can anyone tell me what I am doing wrong.
View Complete Forum Thread with Replies
Related Forum Messages:
PASSWORD() Function :: Not Matching Passwords
I'm writing a login.php script for my web site and am encountering some problems matching the password of the user logging in. Here's some of my code where I believe the problem to be: $query = "SELECT user_id, first_name FROM users WHERE username='$u' AND password=PASSWORD('$p')"; echo($query); $result = mysql_query ($query); $row = mysql_fetch_array ($result, MYSQL_NUM); if ($row) { // Start the session, register the values & redirect. session_start(); $_SESSION['first_name'] = $row[1]; $_SESSION['user_id'] = $row[0]; header ("Location: [url]http://"[/url]; . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/loggedin.php"); exit(); } else { $message = '<p>The username and password entered do not match those on file.</p>'; } mysql_close(); } else { $message .= '<p>Please try again.</p>'; } } I keep getting my error message "The username and password entered do not match those on file" listed above in the conditional. The server doing my hosting is running MySQL 4.1.14 - standard. The test login script that is getting passed prints out as follows: SELECT user_id, first_name FROM users WHERE username='test' AND password=PASSWORD('test1') Am I doing something wrong with the PASSWORD() function?
View Replies !
Matching SQL And Database Query
If I open up phpMyAdmin, click on a database named Gypsy, then click on the SQL tab and paste in the following: GRANT ALL PRIVILEGES ON Gypsy.* TO 'James_Bond'@'localhost' IDENTIFIED BY î‘' FLUSH PRIVILEGES; I know it's at least partially working because I see James_Bond listed among the users when I click on "Privileges" - and I don't see James_Bond listed for any other database. But when I try the following database connection... PHP $link = mysql_connect ("localhost" , "James_Bond", "007") or die(mysql_error()); mysql_select_db ("Gypsy", $link) or die(mysql_error()); I get this error message: Quote: Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'James_Bond'@'localhost' (using password: YES) in /Users/MyName/Sites/Geobop/index.php on line 194 Access denied for user 'James_Bond'@'localhost' (using password: YES)
View Replies !
Database Password
I was trying to install a mod that connects to my forum database and it prompted me for my database username password...and I can't remember it. Is there something I can do in cpanel or something to recover my password?
View Replies !
Password In Database
1- how to hide passwords to be shown by database administrator? 2- how to validate using SQL statement the typed password to the hidden password in database
View Replies !
Username, Password And Database Name
but the person that installed mysql on my laptop told me that the username and database name was not that important. Is there a way to retrieve my username, password and database name? Im trying to practice php and mysql but it give me an error.
View Replies !
Password Database Security
Is it a safe idea to store and use a username and password out of a mySQL DB for logging into basic private pages? Does mySQL encrypt the table data if somehow specified? Is there a simpler way of doing this? without a DB?
View Replies !
How Do I Change A Database Password?
I have created a MySQL database on my local server and set up my php pages etc. using phpMyadmin and Dreamweaver. When I tried to set up a database on my server I discovered a small problem. I had used a 15 character password and my server limits the password to 12 characters. My simple question is can I change the password of the database and if so how. I am very new to using these toold so please make your answer clear and simple so that I can follow. I have instaled the MySQL GUI Tools as well but can't figure out how to change a password.
View Replies !
How To Encrypt Password In MySQL Database?
i would like to ask thing son encryption of data presently i'm setting up a mysql database to store usernames and password for authentication is there ways i can encrypt the column passwords even to the database administrator? i know of MD5 but how do i actually go about doing it?
View Replies !
Can I Set Database User Password When No Root Pw Is Set
I have installed PHPBB MediaWiki and SugarCRM on Ubuntu Server LAMP. I initially tried to set the root password on install and then could not log back in. After reinstall this is what I did for a new non root user. root@invest:~# mysql -V mysql Ver 14.12 Distrib 5.0.38, for pc-linux-gnu (i486) using readline 5.2 grant CREATE,INSERT,DELETE,UPDATE,SELECT on pauldb.* to paul@localhost; set password for paul = password('mysecretpassword'); flush privileges; exit; Then when i go to login with this user I can't. I have not set a password for root because the same thing happened when I tried to set root pw immediately after install of the database. This time I am trying to work out the access issue with a new user i have created. This way I still have access since and I won't have to reinstall the db.
View Replies !
Used Mysqldump To Dump Database But Its Not Accepting Password?
I am trying to dump the database but can't because sometimes I get error 2002 which is cannot connect to local MySQL server through socket 'tmp/mysql.sock' and sometimes I get error error 1045 which is access denied for user (Using password: YES). Isn't the password the same as the password to access mysql or is to the password to access the shell a/c. The username and password should be that of the shell account or the mysql account?
View Replies !
Random Password Vs. User Created Password For Site Login
Are there any security issues or other concerns that make one preferable? The client is pushing for user created passwords. I'm mapping out the basic functionality and front-end for a MySQL/PHP back-end that will be completed by a third party. I'm a novice to MySQL but familiar with PHP and their interaction. Mainly looking for anything to support one method over the other.
View Replies !
Mysql Password() & Unix Crypt Password...
I am creating a user administration system where system administrator can activate services for a user, like webspace, a mail account or a subdomain. I now want to create a function that creates mysql databases and grant the right privileges to a user. But the problem is that mysql wants to have the plaintext password for the user in the "grant ... identified by 'pwd'" field, or in a manual query to update the password in the mysql.user table with PASSWORD('pwd'). I have another database which holds the passwords for the users, these password are stored the moment a user signs up and are used to activate services, for example ssh access to the machine. The stored passwords are encrypted using crypt(). So for adding a ssh service to a user, I simply do echo "$user:$pwdhash" | chpasswd -e. I have chosen crypt because some programs (like proftpd) don't take md5 sums. The problems is that I don't have the plaintext password. So I cannot add a mysql db. So I need to create a user in mysql with a crypt password. I tried to just "grant all privileges ... identified by 'nothing'" and then afterwards update the mysql.user table and putt the crypt password in there but it doesn't work like that. Does anyone have any idea on how I could fix this, how can I create a user in mysql without having his plaintext password and only having a crypt hash of it. I thought about not only storing a crypt hash, but also an md5 hash and a mysql PASSWORD() hash.. but I think that's an ugly solution.
View Replies !
I Can Connect With Db Password Or Blank Password
I have a password setup for root (% and localhost) in Mysql 5.0.26, I can connect ok no problem. I can also connect with blank password! I know it is checking the password cuz it fails if it's wrong. I'm sure I have only one account as well (tried to delete, recreate, etc... no change) select * from user where user='root'; | localhost | root | *F3AD8B3C44772C17F66767F29D948D9C255BD824 | Y ... | % | root | *F3AD8B3C44772C17F66767F29D948D9C255BD824 | Y ... Is there an option to accept blank password!? I have this problem only for root user; Other accounts are fine.
View Replies !
How To Do LIKE Matching In A.Name=b.Name
I have a statement as follows Code: SELECT * FROM tb1, tb2 WHER tb1.Name = tb2.Name I would like to do fuzzy matching on the name field. I need something like Code: SELECT * FROM tb1, tb2 WHER tb1.Name LIKE '%tb2.Name%' Also, I tried with Code: SELECT * FROM tb1, tb2 WHER LOCATE(tb1.Name, tb2.Name)<>0
View Replies !
Matching Results
Suppose you have two tables: A and B. Both tables have the same columns: col1, col2, col3, etc. So my records are distributed in two different tables that have the same format. I know, this is not good normalization design, but that is the way they are setup right now. The question is: how do I query both in a single sql statement, combine the results of the query get all the records from both, and list the result in alphabetical order? I can do: select * from A ORDER BY status; and I can also run: select * from B ORDER BY status; But how do I run both at the same time and get a single output from them?
View Replies !
Matching Profiles
I am working on a dating website and have to match profiles that are stored in multiple tables. What I am trying to do is to sort results in a descending order starting from best match to the worst, so what I thought of is to use the Levenshtein or similar_text functions on the different values stored in the profile, but later I realized that such an idea would be very time consuming when dealing with thousands records. Here is an example that shows the structure of my tables: member[id, login] look[id_mmeber, weight, hair_color, eyes_color, have_galsses] pref[id_member, smoke, drink, like_clubbing, like_cafes] In reality , the profile have more than 3 tables, but 3 will be enough to explain it So the big question is, is there a way to acheive this by using SQL only ?
View Replies !
Matching Id Numbers
I have a problem with a user management system. Simply i have 3 tables. Table 1 - ID1, Name, Pass Table 2 - ID2, Name, ItemID Table 3 - ID3, ItemID, ItemName Let user login using info from table 1, once logged in query table 2 to get all the ItemID's for the logged in user.Once this is done I need to finally query table 3 looking for matches to the itemid's from table 2 in order to show how many orders for each item but only when the itemid is associated with the user from tables 1 and 2.
View Replies !
Matching Strings
I have a lot of records in a table named in this pattern "this text is the same.r01 someText (001/100)", "this text is the same.r01 someText (002/100)", "this text is the same.r02 someText (003/100)" etc. The idea is that i want to automate the process of recognizing the files belonging to the same file(.r02 in this case), and then set a value which shows that is belongs to a certain fileID in another table. The problem is that i have no idea what would be the best way to do this. My initial guess is that i would have to use a trigger and a LIKE clause comparing the "this text is the same.r02" part of the string, to see if it already exists in the database. If it does, i have to mark it as belonging to the same file. I guess using a LIKE clause would be very slow, and the amount of records will grow quite big(millions of rows).
View Replies !
Bitwise Matching
I am using an unsigned INT to store a list of categories for a particular product. Some products can be listed in multiple categories. For example, categories might be 1-Stationery, 2-Furniture, 3-Hardware, etc. When an item is in multiple categories, i just set the appropriate bit, for example an item that might be listed in stationery and hardware would have bits 1 and 3 set to 1, givng the category a value of 5. A search then uses a bitwise & to return values based on a user search, for example if a user searches for "stationary and hardware" Item 1 = 101 (binary) Search = 101 (binary) Result = 101 (item1 binary). What I would like to know is if it's possible to order the results in order of the number of matching bits? For example 2 items, first with bits 101 set, second with bits 100 set, I would like to return both items, but obviously rank the one with most bits matching the search higher. Is this possible?
View Replies !
Many To Many Matching Query
Bit stuck on a query, or, at least on the best place to start. I've got two tables with a many-to-many relationship. Those are linked by a third table, giving a one-to-many, via a join. Say the one table is products, and the other stores. So, what I can do, is list a store, and all it's products (probably the other way round, but there's no need for that at the moment). They are linked by the third table, product_stores. What I'd like to do, is be able to find all stores, where a specified two products are stocked. So I can find say, a list of stores that will have apples and oranges, and be able to list all those stores, ignoring stores that stock only one of those. The first type of query is basic enough "SELECT * FROM product_stores WHERE productid = $variable. This select is performed on a vew in MySQL. Any suggestions where to start? I know the logic would be find all products where storeid = $variable1 and storeid = $variable2 and then make sure you have a matching pair. My current tables are: Products ProdID, ProdDescription, etc. Stores StoreID, StoreDescription, etc. Products_Stores (sits between the many-to-many) StoreID, ProdID, etc.
View Replies !
Matching Two Tables
I am trying to pull information from two different tables to be displayed in a php file. Both of these tables share the same field of product_id. I need to pull the product name from one table and the location of the image from another table and display them. This is for a store system and I'm randomly trying to show three products on my homepage. I am just unsure as to how to pull the information. I have code that connects to the DB already and randomly grabs a product name. My next step I am guess is to match the product_id of the name pulled to the other table and get the filename of the image stored in the other table. This is the code I already have. <?php $link = mysql_connect("localhost", "tristate_store", "pword") or die (mysql_error ()); mysql_select_db ('tristate_store', $link) or die (mysql_error ()); $desc = mysql_query ("SELECT * FROM `storeproducts_description` ORDER BY RAND() LIMIT 0,1") or die (mysql_error ()); $res = mysql_fetch_assoc ($desc); echo ''. $res['products_name'] . ' Click here ' . $res['products_id']; ?>
View Replies !
Pattern Matching?
I have some data I want to pull out of one field and put into another. The tricky part is that the field the data is in is a text field, and the data could be anywhere in there. So I need to do some sort of pattern matching to find it. Here is an example of the query I want to run, but I don't know what to put for the question mark. UPDATE Building SET architect = ? WHERE description LIKE '%Architect: %'; In the description field, architects are in this format: Architect: name of architect or Architect: name of architect, http://example.com/ The name of the architect may contain commas. So the pattern match needs to do this: Find "Architect: " then find ", http://" or " " or end of field after that take the text in between and put it in the architect field.
View Replies !
Matching Escaped Strings
I have the following info in my database ID|Name ================ 1|Author's As you can see, the name value has been escaped. Now, the question is, how do you match on a value that has escaped charaters? I've tried the following SELECT * FROM table WHERE Name = 'Author's' SELECT * FROM table WHERE Name LIKE 'Author's' SELECT * FROM table WHERE Name = '%Author's%' SELECT * FROM table WHERE Name = 'Author''s' SELECT * FROM table WHERE Name = "Author's" SELECT * FROM table WHERE Name = "Author's" And none of them work.
View Replies !
Mysql String Matching
I have string in a field like theses: rel-1-0, rel-2-0, rel-3-0, rel-21-0. If comparing them in this way: select 'rel-3-0'>'rel-21-0'; Mysql will return "1" as true, this is false in our knowledge. I wonder if there is a way to order such string inside mysql so that rel-3-0 < rel-21-0?
View Replies !
Get Count Of Matching Records
I have two tables, that I am trying to match up rows and count the number of times first_name AND last_name in table A match first_name AND last_name in table B. What is the best way to do this without creating a mess of queries and code?
View Replies !
Pattern Matching Titles
I am having problems trying to do a pattern match between two tables. I have a table with and id column and a title of a book. In the second I have the title and the author. I want to take the title from second table and retreive the id from the first matching the titles?
View Replies !
Matching Partial Strings
I've been working all day trying to figure out how to do this query and have exhausted all of my resources.i'm trying to find relationships between the 'category' field of my "songstab" table which can contain more than one category separated by commas and the 'category_set' field of my "category" table which has all of the possible categories as it's rows. it works fine if there is only one category in 'songs.category' but doesn't return anything if there are more than one item (ie. Drama,Comedy,Action). how can i get it to recognize the partial string matches?
View Replies !
String Matching Across 2 Tables
I have 2 tables. Table 1 has 2 columns; address (varchar), ID (int) Table 2 has 1 column; town_name (varchar) table1.address is a string which contains a town_name. I want to produce a query result that has each address matched up to the correct town_name. Ideally i would extract the town name directly from the address string but the position of the town name in the address string is impossible to specify.
View Replies !
Matching Multiple Rows
I've got the following tables with the following columns: property: id, address, number_of_bedrooms attribute: id, title (e.g. washing machine, central heating, furnished) property_attribute: property, attribute (composite primary key on both id columns) what i'm trying to do is select property ids that have all the attributes i'm looking for, for example, all those properties that have a washing machine and are furnished. I've been trying things like the following which aren't working, probably because the attribute column won't be equal to two different values at once. SELECT pa.property FROM property_attribute AS pa INNER JOIN attribute AS a ON pa.attribute=a.id WHERE a.title='washing machine' AND a.title='furnished' this is returning an empty set because, i think, a.title can't have two values at once. what i want to say in pseudo-sql is: SELECT pa.property FROM property_attribute AS pa INNER JOIN attribute AS a ON pa.attribute=a.id WHERE (pa.property=X AND a.title='washing machine') AND (pa.property=X AND a.title='furnished') so the only results that will be returned are where a property has both attributes. i can't think of how to do this since there will be varying numbers of attributes i need to search on. perhaps i need to use a variable for pa.property - i tried that, setting it to SELECT DISTINCT property FROM property_attribute, but mysql didn't like it because this query returned multiple rows. i may need some kind of set variable or an array.
View Replies !
RE Table Name Matching Function
how one would go about specifying a table name in a select statement where the table name is also the name of a function. I know it's poor database design, but unfortunately it's the way it was made many years ago. The table name is "year" and of course, there is a function called "year". I tried single and double quotes, but that doesn't seem to work I tried searching the documentation, but I haven't found anything.
View Replies !
Select All Matching Rows
I need to look in table 1 and pick all those records not in table 2.I know that table 2 has 51000 records and table 1 has 65000. I want to see the 14000 in table 1 that doesn't have a match in table 2
View Replies !
Regexp Matching *.domain.com
I don't think this is possible, but perhaps it's just beyond me? I have a database of domain names. other1.com *.test.test.com test.com *.other2.com How can I validate domain name search like "test.com" = valid domain "other.test.com" = invalid domain "other.test.test.com" = valid domain Here's my attempt, but i'm not even close. SELECT * FROM `dns` WHERE `DNS_Lookup` REGEXP ^([^.asterisk.])([.period.])(".$_DNS_SEARCH.")$';";
View Replies !
Limit On Matching Results Only?
Is there a way to do a limit with a starting and ending value that works like a: LIMIT 10, 20 only it pulls the 10 resulting rows that matched the where clause of the query vs. just showing the 10 rows regardless of the where clause? Example: select product_name from products where product_count > 0 limit $start, $end; The desired result is that the query returns however many rows fall between the value of $start and $end, lets say 10 rows, but the 10 rows returned are the first 10 rows that matched the where clause of the query and not just the next 10 rows of the table.
View Replies !
Matching A String To Text
What is the best query to use optimized for speed that will search a table for rows where the column value is contained in a block of text that is stored in another table? For example, if I am storing "Blue, Yellow, Purple, Green" in one large text value in the "color" column of table "Crayons", how do I SELECT the rows in the "Todays_crayons" table if the value in the "color" column matches any of the values in the "color" column (the text block) of the "Crayons" table?
View Replies !
Pattern Matching With REPLACE()
I am trying to sort results using a selective case-insensitive REPLACE() of "the " only at the beginning of the string like this: SELECT * , REPLACE( title, '^the ', '' ) AS sortName FROM testing ORDER BY sortName; Which produces: +----+----------+----------+ | id | title | sortName | +----+----------+----------+ | 3 | Ants | Ants | | 1 | flag | flag | | 4 | the aunt | the aunt | | 2 | The fog | The fog | +----+----------+----------+ Now I can do this: SELECT * , REPLACE( title, 'the ', '' ) AS sortName FROM testing ORDER BY sortName; Which is a little better: +----+----------+----------+ | id | title | sortName | +----+----------+----------+ | 3 | Ants | Ants | | 4 | the aunt | aunt | | 1 | flag | flag | | 2 | The fog | The fog | +----+----------+----------+ Is there some way to use regex terms with REPLACE() ?
View Replies !
SQL/PHP Grabbing And Matching Case
I've made a nice login script and I thought it was bug free. But I've come to realize that if you don't have the same case as you did when you registered (e.g. Registered as As5a5sIn5,Logining into as5a5sin5 won't work!) it refuses to let you sign in. My question today is, how can you grab data from mysql and match it through PHP case insensative.
View Replies !
Output Only Displays Matching Value
I have two tables, Table1 and Table2. When i submit a name from my form ( eg : jimmy ), 'jimmy' is inserted into both tables. Now this part is fine. In the output, it displays the data from both tables ( output: jimmy - jimmy ) The problem i am having lies in my sql statement i believe. Basically, the way i have it now, it says, if 'jimmy' is in Table1 AND in Table2, output the results, otherwise forget it! It does not output anything if 'jimmy' is in NOT in Table1 but IS in Table2, or vice versa. My code : $result = mysql_query("SELECT". "`TABLE1`.username,". "`TABLE2`.username ". FROM". "`TABLE1`,". "`TABLE2`". "WHERE". "`TABLE1`.username = `TABLE2`.username ". "") or die(mysql_error());
View Replies !
Character Matching Question
Is there any special character to be used if in the following query, i don't care about the user's gender, (that is, i want to have as result both men and women)??? I'm trying: $query="SELECT * FROM users WHERE gender LIKE '%' "; or $query="SELECT * FROM cast WHERE gender LIKE '.' "; or $query="SELECT * FROM cast WHERE gender LIKE '*' "; but none seems to work.
View Replies !
Matching Keyword Lists
I have a table with 2 fields: aid and keyword. aid stands for an article and keyword is a keyword in that article. Each article has of course multiple keywords (+/- 200). What I'm trying to do is find out which articles have the most keywords in common. I have found a way to do this, but am afraid this will explode once I have a substantial amount of articles: Code: SELECT aid, count(*) as r FROM `articleKeywords` WHERE keyword IN (SELECT keyword FROM articleKeywords WHERE aid = 1) AND aid != 1 GROUP BY aid ORDER BY r DESC Is this the right way or are there better ways to do this?
View Replies !
Need Help With Matching A Range Of Character In A Query
The following query (modified from original to make it easier for you to read) select all of the clients whose fisrt initial of their last name equals a specified character ($lastInitial). It works fine for characters A-Z but I need to know what to set $lastInitial to for it to select clients last names that start with a different character than A-Z such as a number or some kind of punctuation. select * from Clients where left(lastName,1) = $lastInitial order by lastName ASC
View Replies !
|