Jump to content

Posting to mysql and sending emal


QuizToon

Recommended Posts

Hi all,

 

Is it possible to check an entry against a database before deciding how to process.

 

EG

 

I have a basic contact form, Name, email, message.  What I would like to happen is when the user hits the submit button I want to check if the email address already exists in the database.  If it doesnt I want to post the info to a new record, if it does i dont want to post anything to the database, in both instances I want to send the form to an email recipient.

 

If it is possible to do this please can someone either tell me where I will find a good tutorial which covers it or what search terms should I be searching for.  I have tried for ages and just dont get the right results when I try to google.

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/163994-posting-to-mysql-and-sending-emal/
Share on other sites

$result = mysql_query("SELECT `email` FROM `members` WHERE `email`='{$email}' LIMIT 1");
if($mysql_num_rows($result)>0) {
// you already have this user in the database
} else {
// You don't and should put an INSERT query here.
}

 

Of course, thats just an example.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.