Results 1 to 2 of 2

Thread: If else statement & sending an html email
      
   

  1. #1
    Antonio878's Avatar
    Antonio878 is offline Master Sergeant
    Join Date
    Sep 2007
    Posts
    68

    Exclamation If else statement & sending an html email

    I want to send an email but here is the thing, if the person selects the button 1 then it will send the email but if they select 2 it won't send the email but do something else.
    Here is the code:
    PHP Code:
    <?php 
    if($vote<>"2"){ 
    ?>
    <?php
    $HTML 
    "You have selected 1 as your vote! here is the code: 4837583";
    $from no-reply@domain.com;
    $to "$emailer";
    $subject "Tester";
    sendHTMLemail($HTML,$from,$to,$subject);
     
    function 
    sendHTMLemail($HTML,$from,$to,$subject)
    {
    $headers "From: $from\r\n"
    $headers .= "MIME-Version: 1.0\r\n"
    $boundary uniqid("HTMLEMAIL"); 
     
    $headers .= "Content-Type: multipart/alternative;".
    "boundary = $boundary\r\n\r\n"
    $headers .= "This is a MIME encoded message.\r\n\r\n"
    $headers .= "--$boundary\r\n".
    "Content-Type: text/plain; charset=ISO-8859-1\r\n".
    "Content-Transfer-Encoding: base64\r\n\r\n"
     
    $headers .= chunk_split(base64_encode(strip_tags($HTML))); 
    $headers .= "--$boundary\r\n".
    "Content-Type: text/html; charset=ISO-8859-1\r\n".
    "Content-Transfer-Encoding: base64\r\n\r\n"
     
    $headers .= chunk_split(base64_encode($HTML)); 
    mail($to,$subject,"",$headers);
     
    }
    ?>
    <?php 
    }
    else
    {
    echo 
    "";

    ?>

  2. #2
    Watdaflip's Avatar
    Watdaflip is offline Major General
    Join Date
    Sep 2005
    Location
    Cincinnati, Ohio
    Posts
    2,116

    Default Re: If else statement & sending an html email

    I would change the if statement to
    PHP Code:
    if($vote == 1
    The way it is now, it is just checking if its not equal to 2, which could mean its 1, or it could be 3, or nothing and it will still send the email.

    Also $vote needs to be set somewhere beforehand

    Register/Login Script
    Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49