Announcement

Collapse
No announcement yet.

If else statement & sending an html email

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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 
    "";

    ?>
    Check out:
    Great Windmill (A Place Where You Can Have Fun!)

    You can do so much on the website, check it out!

  • #2
    Re: If else statement &amp; 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

    Comment

    Working...
    X