Emailing Values from a Checkbox

the mail() function

Moderators: egami, macek, gesf

Post Reply
User avatar
egami
php-forum GURU
php-forum GURU
Posts: 2192
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Fri Feb 10, 2012 6:54 am

Code: Select all

//example
<form name="testme" method="post" action=".">
<input type="checkbox" name="sendmeemail" value="1"> Send Me E-Mail <br />
<input type="checkbox" name="sendmesnailmail" value="1"> Send Me Postal Mail <br />
<input type="submit" name="action" value="Submit">
</form>

Code: Select all

<?php
if (isset($_POST['action']) && $_POST['action'] == "Submit") { 
  if (isset($_POST['sendmeemail']) && $_POST['sendmeemail'] == 1) { 
    echo "YAY! You want E-Mail! <br />\r\n";
  } else { 
    echo "You chose not to receive E-Mail <br />\r\n";
  }
  if (isset($_POST['sendmesnailmail']) && $_POST['sendmesnailmail'] == 1) { 
    echo "Yay! You want to receive snail mail! <br />\r\n";
  } else { 
    echo "You chose not to receive snail mail. <br />\r\n";
  }
}
 

Post Reply