Jump to content

Sending an e-mail if an argument is made


spoco

Recommended Posts

I have a form that is sending the data to a MySQL database. I want to send an e-mail when an ID is submitted that matches an ID already in the database.

 

For example

 

If I submit ID 123, Name: John, the data is written to the database

If I submit ID 123, Name: John again, the data is written to the database and an e-mail is sent alerting that a duplicate ID was entered.

 

It would be setup in an IF statement, correct? This isn't right but something like:

 

<?php 

if(ID=ID)){
}

$email_to = "[email protected]";
$email_subject = "Test E-Mail (This is the subject of the E-Mail)";
$email_body = "This is the body of the Email \nThis is a second line in the body!";

?>

 

I would appreciate any help with this.

yes, you can do a query like this

$result = mysql_query("SELECT * WHERE field1='$variable1' AND field2='$variable2'")//variables are from your post data or wherevever
//if (mysql_num_rows($result) != 0){
//send the email;
}

 

that will check for any rows matching the criteria, and if there are any, you can send an email

The field name that I want to check is called msis

 

I have this code in there:

 

$result = mysql_query("SELECT * WHERE msis='msis'")

if (mysql_num_rows($result) != 0){

$email_to = "[email protected]";

$email_subject = "Test E-Mail (This is the subject of the E-Mail)";

$email_body = "This is the body of the Email \nThis is a second line in the body!";

 

and the page will not even load.

$result = mysql_query("SELECT * WHERE msis='msis'")

 

that will return all rows where the string string 'msis' is in the column msis. If you want to test a variable, you have to put a variable in there. And are there any errors? check the source for errors also.

oh yeah, sorry about that.

 

I don't have a variable, I need it to look in the database and see if the msis number exists.

 

what exactly is this msis number? is it constant? will it change? if it will change that you need a variable

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.