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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.