Re: SQL-HELL! How select-query with query for UID / PWD
| From: | Ryan Adams | Date: | Wed, 24 May 2000 15:11:19 +0000 |
| Subject: | Re: SQL-HELL! How select-query with query for UID / PWD | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-431@lists.php.net to get a copy of this message | ||
hmm... sounds like you might have to do it in 2 queries. For instance
// 1. Run user query
$u = mysql_query ("select * from users where userid='$userid' and
pword='$pword'");
// 2. Make sure they're in the table...
if (mysql_num_rows($u) > 0) { // returned a row?
// 3. run product query
$result = mysql_query ("select * from product");
// do stuff with result
}
Note: if the 'products' table is linked to users (products has a userid field), it might
be possible to do something like:
select products.* from users, products where users.userid=product.userid
and users.userid='$userid' and users.pword='$pword'
-Ryan
*************************************
Ryan Adams
Online Systems Development
College of Family & Consumer Sciences
The University of Georgia
Athens, GA 30602
(706) 583-0344
radams@fcs.uga.edu
*************************************
On Wed, May 24, 2000 at 12:46:10PM +0200, helmut ott wrote:
> Gott der Gerechte... SQL macht wahrhaft demütig.
>
> I have a mysql-table, containing a field userid as a relation to the field userid in table
> users.
>
> I query this table for all records, using
>
> $result = mysqlquery("quarti","SELECT * FROM resume)
>
> - ok so far:
>
> ----> Now, what, if I want allow the execution of this query only to users with a valid
> password and userid, as contained in their record in the table users?
> I have entry variables $uname and $pword in the authentication routine.
>
> $result = mysqlquery("quarti","SELECT * FROM product WHERE
> username.users=$uname, password.users=$pword)
>
> What is wrong with the above sql (or what isn´t)?
>
> Thanks for a light.
>
> Helmut
>
>
>
---end quoted text---