Jump to content

Sending e-mails after verufying through checkbox.


Javitri

Recommended Posts

Hello I am working on php website. Now here im working on sending orders. So once it is ordered the confirmation e-mail goes to one who ordered(he enters his e-mail id manually) and the head of the department(e-mail ids written in code).

But now I have put a checkbox that if the person is head of the department he checks the checkbox and e-mail should be sent to him. So how to verify this by checkbox.Can anyone please help me with this. The person should not get 2 e-mails.

I hope I was clear in explaining my doubt. If not please do ask me for more explanation.

Thank you.

Link to comment
Share on other sites

Checking whether or not a checkbox was checked is easy in PHP.

 

On your HTML page you have the checkbox, I will call mine "send_email"...

 

<input type="checkbox" id="send_email" name="send_email" value="1"> Send me an email

 

On the following PHP page, the one used in the <form action="myscript.php"> tag you will get the value with the POST array like so:

 

$send_email = $_POST['send_email'];

 

Then just check that value if a conditional:

 

if ($send_email) {
     // send an email to them
}
else {
    // don't send an email to them
}

 

You may want to grab an email validation script that makes sure it is a valid email address too, and run $_POST['send_email'] through that first, and maybe even sanitize it too, before processing it, just to be safe...

 

Link to comment
Share on other sites

#

$departments = array("access"=>"Access Services",

#

"advancement"=>"Advancement",

#

"archives"=>"Archives",

#

"closet"=>"Supply Closet",

#

"digital"=>"Digital Library Management",

#

"dmds"=>"DMDS",

#

"metadata"=>"Metadata Management",

#

"office"=>"Office of the Dean",

#

"research"=>"Research & Instruction",

#

"resourcem"=>"Resource Management",

#

"resource"=>"Resource Sharing",

#

"scholarly"=>"Scholarly Resources",

#

"systems"=>"Systems" ,

#

"others"=>"Other");

#

$to = array("access"=>"d.kennedy@edu",

#

"advancement"=>"m.carpenter@.edu

#

"archives"=>"j.krizack@edu",

#

"closet"=>"e.bren@edu",

#

"digital"=>"p.yott@edu",

#

 

"research"=>"j.dendy@edu",

#

"resourcem"=>"j.morrow@edu",

#

"resource"=>"br.greene@edu",

#

"scholarly"=>"a.aaron@edu",

#

"systems"=>"r.krol@edu",//r.krol

#

"others"=>"sharma.me@edu");

#

 

#

 

#

 

 

 

now after checkbox is verified it sends to head of the department means the e-mail ids listed  so how do I write them in if condition.

again in if condition how to see whether it goes to that particular head and if not then it should go to both the person who entered his e-mail id and to the head(e-mail ids listed above).

Link to comment
Share on other sites

So for clarification: the head of the departments email address is hard coded into the PHP file and he gets a copy of the email that also goes to the person who ordered the item, correct? But, you want to check if the person who ordered the item is actually the head of the department himself, and set it so that he doesn't get two emails, i.e. one sent to him as the user and one sent to him as the head of the department? I'm also assuming that all of the email addresses listed in your array the various heads of departments, correct?

 

1. If that is not correct, let me know.

 

2. If it is, try this code:

 

Assuming that the email address that the user entered was passed to this code through the $_POST['user_email'] variable....  you just need to check if the $user_email address is also in the $to array, and act accordingly:

 


$user_email = $_POST['user_email'];

if (in_array($user_email, $to)) {
    
      // send only email to $user_email

}

else {

    // send email to $user_email
    // send email to department head

}

 

 

I hope this helps. If not, respond here, I get an email when there is a new response and I am in my studio for the next 10 hours at least.

 

Link to comment
Share on other sites

I did work on this but it sends double copy now to both the people the checkbox thing doesnt seem to work.

Its like even if I click the checkbox or not it sends 2 copies to both:(:(:(

Can I please have ur e-mail id(if its fine with you) where i can send u both the files. For some reasons I am sorry cannot upload them here.

 

Link to comment
Share on other sites

  • 2 weeks later...
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.