Whether a userid is already in databse

R

Regent

Hi friends,

I'm doing some cgi programming these days, using MS Access database to store uid/pwd info from registration forms in HTML pages. I considered

SELECT from Users WHERE userid = '$uid'

to see whether the received uid (from webpage forms) is already in the database, but I guess there may be more convenient ways to do this?

Thanks for ur advice!

Regent
(e-mail address removed)
 
T

Tintin

Regent said:
Hi friends,

I'm doing some cgi programming these days, using MS Access database to
store uid/pwd info from registration forms in HTML pages. I considered
SELECT from Users WHERE userid = '$uid'

to see whether the received uid (from webpage forms) is already in the
database, but I guess there may be more convenient ways to do this?

What would Perl programmers know or care about SQL.
 
N

Nick Santos

Regent said:
Hi friends,

I'm doing some cgi programming these days, using MS Access database to
store uid/pwd info from registration forms in HTML pages. I considered
SELECT from Users WHERE userid = '$uid'

to see whether the received uid (from webpage forms) is already in the
database, but I guess there may be more convenient ways to do this?
Thanks for ur advice!

Regent
(e-mail address removed)
I use MySql, and that's the way I do it, simply checking to see if anything
is returned. I think it's fairly effective, because it doesn't require much
coding either.
 
R

Regent

------------------------
I use MySql, and that's the way I do it, simply checking to see if anything
is returned. I think it's fairly effective, because it doesn't require much
coding either.

Thanks, and how do you check by the way?
 
K

Keith Keller

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

What would Perl programmers know or care about SQL.

Many Perl programmers know and care about SQL. Why any of them should
answer SQL questions in a Perl newsgroup is another question altogether.

- --keith

- --
(e-mail address removed)-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/9RWchVcNCxZ5ID8RAnKwAJ9Du/s2oR0pmeyteNxjM1AGAHJIwACeMN3/
5u39HJyjfY7wXPwmYBQyXWU=
=NMz2
-----END PGP SIGNATURE-----
 
L

Lawrence D¹Oliveiro

Tintin said:
What would Perl programmers know or care about SQL.

I write a lot of Perl (as well as C and other languages), and I use a
lot of SQL with it. I have also used PHP with SQL, and guess what--I
think Perl DBI is more advanced than anything PHP can offer.
 
G

Gregory Toomey

It was a dark and stormy night, and Tintin managed to scribble:
store uid/pwd info from registration forms in HTML pages. I considered
database, but I guess there may be more convenient ways to do this?

What would Perl programmers know or care about SQL.

Lots. Well I've been using SQL for 15 years, and answer a lot of SQL questions here.

The above query I would probably change to
SELECT count(*) kount from Users WHERE userid = '$uid'

then test for kount>0 (using the DBI syntax to reference kount).

gtoomey
 
R

Regent

Lots. Well I've been using SQL for 15 years, and answer a lot of SQL questions here.
The above query I would probably change to
SELECT count(*) kount from Users WHERE userid = '$uid'

then test for kount>0 (using the DBI syntax to reference kount).

Thanks. The idea is to check if the uid already exists and if not INSERT the new user into the db.
Now that the SELECT is already a filter, I think this filter must be cancelled before the INSERT operation, right? How do I cancel this filter without disconnecting the db? Thanks again
 
R

Regent

Lots. Well I've been using SQL for 15 years, and answer a lot of SQL questions here.
The above query I would probably change to
SELECT count(*) kount from Users WHERE userid = '$uid'

then test for kount>0 (using the DBI syntax to reference kount).

Thanks. The idea is to check if the uid already exists and if not INSERT the new user into the db.
Now that the SELECT is already a filter, I think this filter must be cancelled before the INSERT operation, right? How do I cancel this filter without disconnecting the db? Thanks again
 
G

Gregory Toomey

It was a dark and stormy night, and Regent managed to scribble:
Thanks. The idea is to check if the uid already exists and if not INSERT
the new user into the db. Now that the SELECT is already a filter, I think
this filter must be cancelled before the INSERT operation, right? How do I
cancel this filter without disconnecting the db? Thanks again

I'd just do an insert, and check the return code. If its OK, or record already present, then that's whay you want.

If you do a select followed by insert, you are adding an extra database access. This may be significant if you are dealing with lots of records.

gtoomey
 
M

Matt Garrish

Regent said:
Hi friends,

I'm doing some cgi programming these days, using MS Access database to
store uid/pwd info from registration forms in HTML pages.
MS Access is a toy (and an ugly, resource-intensive one at that). Get MySQL.

Matt
 
R

Ragnar Hafstae

Regent said:
Thanks. The idea is to check if the uid already exists and if not INSERT the new user into the db.
Now that the SELECT is already a filter, I think this filter must be
cancelled before the INSERT operation, right? How do I cancel this filter
without disconnecting the db?

there is no such thing in SQL

the correct way is just to INSERT. if the user is already present,
you will get an error (assuming userid has a unique constraint)

if you want to select first, then you need use lock or transaction
to ensure no other process create the record between your select and insert

anyways, you should test the result of your insert anyways, so why
bother with a previous select?


gnari
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top