[thelist] sql for mailing list verify

NanHarbisonSmith at aol.com NanHarbisonSmith at aol.com
Thu Jul 25 20:19:01 CDT 2002


--
[ Picked text/plain from multipart/alternative ]
Is this in a web page, are you using ASP, PHP, something else? I don't use
SQL for this, I use PHP and it is easy to do, but it depends on the language.
 I use this code in PHP, when members sign  up for a username and password,
where the username has to be unique:

//see if the username is already in the db
$Query1 = "SELECT USERNAME from $TableName where (USERNAME = '$username')";


$Result1 = mysql_db_query($DBName, $Query1, $Link);

//if there is a match
if (mysql_num_rows($Result1) > 0) {
    $Row = mysql_fetch_array($Result1);

    Print ("The user name <span class=\"bold\">$Row[USERNAME] is already
taken, please choose a different username.</span><br>\n");

Nan

> I have a mailing list that people can add themselves to.  I need to verify
> if the email address already exists in the database before adding them to
> the mailing list.  Is there a simple way to use SQL for this?
>
> Something like 'IF NOT EXISTS 'bob at hotmail.com' THEN INSERT...etc'
>
> Thanks!








More information about the thelist mailing list