Click to See Complete Forum and Search --> : Checking to see if variable exists before insert


Hamsterpants
10-28-2003, 06:31 PM
Hi All,

I have a set up a customer registration form and all is working fine. I am useing the email address as the users log in name, whcih I check to see if it is unique in the database before I add it. I have a second table called newsletter, where, if the user has selected to receive our newsletter, I would like to add. The reason I have a second table is because I would like to offer users who don't want to register all the details as a customer, to register just their name and email address. The problem I am having is checking to see if the email address exist in the table bofore I insert. Does anyone know of a dream wever extention that can do this or can any one suggest how I do about this.

I know in theory what I need to do, but I cant seem to get it to work.

Any help would be appreciated.

Thanks
Dill

TheIceman5
10-28-2003, 11:07 PM
its called php, code a query, dunno if manual coding is foreign to you, u seem to be relying on dreamweaver, ive never used dreamweaver for php coding, i always do manually, lot easier.

olaf
10-30-2003, 08:26 AM
just

$check = "SELECT * FROM table WHERE mail= '$mail'";
$checkResult = mysql_query($check);
$checkRows = mysql_num_rows($checkResult);
if ((isset($checkRows)) && ($checkRows == 0))
{
// begin insert record
}


by the way dreamweaver is a very comfortable php-code editor.