If value exist i table
Posted: Sun Jan 25, 2004 5:21 am
Hi,
I'm making this mailing list for my webshop, and when a user types in an e-mail the script should check is the e-mail already exist in the table. Is there any easy way of doing this? I've tried with the SELECT function inside a if variable, but with any luck.
The part of the script where the if exist have to be:
Thanx
I'm making this mailing list for my webshop, and when a user types in an e-mail the script should check is the e-mail already exist in the table. Is there any easy way of doing this? I've tried with the SELECT function inside a if variable, but with any luck.
The part of the script where the if exist have to be:
Code: Select all
if( $_POSTї'inout']=="in" )
{
if( hghfghgh )
{
//Connects to the database
$link = mysql_connect( $hostname, $username, $password );
mysql_select_db( $db )
or die ( "Couldn't open $db: ".mysql_error() );
//The query adding the data to the database
$query = "INSERT INTO email_list ( `email` )
VALUES( '".$_POSTї'email']."' )";
mysql_query( $query, $link )
or die (" Couldn't add data to "email_list" table: "
.mysql_error() );
mysql_close( $link );
}
}