www.webdeveloper.com
Results 1 to 6 of 6

Thread: Email PHP Form "Confirmation email" - Radio Group Problem

  1. #1
    Join Date
    Feb 2007
    Posts
    133

    Exclamation Email PHP Form "Confirmation email" - Radio Group Problem

    Hi,

    I have a form on a site I am working on. 99% of it all works fine, but there is one thing that is not working.

    This is the form:

    http://www.leighdesignstudio.com/itech/iquote.php

    The problem area is the four radio buttons.
    actually - just the IT services one.

    The validation is all fine. its juts when the email confirmation gets sent to the client. I have spent a while on this and i have it as close as i can get.

    If i select IT services - the confirmation email is CORRECT.
    However, if i select anything else, the one that is correct will appear, but it will also show that i have selected IT services. I have tried various different things. I will put the relevant code here:

    iquote page
    ----------------------------
    <label>
    <input type="radio" name="rdGroup" value="iphone" id="iphone" />
    iPhone </label>
    <label>
    <input type="radio" name="rdGroup" value="ipad" id="ipad" />
    iPad </label>
    <label>
    <input type="radio" name="rdGroup" value="ipod" id="ipod" />
    iPod Touch</label>
    <label>
    <input type="radio" name="rdGroup" value="it" id="it" />
    IT issue</label>

    iquote thanks page
    ----------------------------
    $it = "iT Services";
    $fullmessage .= "Which service are you enquiring about\r\n";
    $fullmessage .= "---------------------------------------------------";
    if ($rdGroup="iphone") {$fullmessage .= "$iPhone\r\n";}
    if ($rdGroup="ipad") {$fullmessage .= "$iPad\r\n";}
    if ($rdGroup="ipod") {$fullmessage .= "$iPod\r\n";}
    if ($rdGroup!="iphone" || $rdGroup!="ipad" || $rdGroup!="ipod") {$fullmessage .= "$it\r\n";}

    I tried this before - also didn't work.
    if ($rdGroup="it") {$fullmessage .= "$it\r\n";}

    if ($rdGroup="it") {$fullmessage .= "IT";}

    Any help would be much appreciated!
    Leigh

  2. #2
    Join Date
    May 2012
    Posts
    17
    Your logical ||'s should probably be &&s

    PHP Code:
    if ($rdGroup!="iphone" && $rdGroup!="ipad" && $rdGroup!="ipod") {$fullmessage .= "$it\r\n";} 

  3. #3
    Join Date
    Feb 2007
    Posts
    133
    When i add this code in - it does exactly as it did before.
    Everything works EXCEPT when i click on IT services as my radio button option. In confirmation email, nothing gets displayed. and i have no idea why. This has never happened before.

  4. #4
    Join Date
    Jan 2009
    Posts
    3,346
    This might be cleaner and easier to check your logic with:
    if ($rdGroup="iphone") {$fullmessage .= "$iPhone\r\n";}
    if ($rdGroup="ipad") {$fullmessage .= "$iPad\r\n";}
    if ($rdGroup="ipod") {$fullmessage .= "$iPod\r\n";}
    if ($rdGroup!="iphone" || $rdGroup!="ipad" || $rdGroup!="ipod") {$fullmessage .= "$it\r\n";}
    PHP Code:
    switch($rdGroup){
       case 
    'iphone':
          
    $fullmessage .= "$iPhone\r\n";
          break;
       case 
    'ipad':
          
    $fullmessage .= "$iPad\r\n";
          break;
       case 
    'ipod':
          
    $fullmessage .= "$iPod\r\n";
          break;
       default: 
    // 'it'
          
    $fullmessage .= "$it\r\n";
          break;


  5. #5
    Join Date
    Feb 2007
    Posts
    133
    That didnt work - it also messed up my validation scripts and my dropdown menu's. I dont know how this can work... the closest i had it was the code i had.. but then IT services was still showing up when i selected anything else.

  6. #6
    Join Date
    Jan 2009
    Posts
    3,346
    Quote Originally Posted by leighchic View Post
    That didnt work - it also messed up my validation scripts and my dropdown menu's. I dont know how this can work... the closest i had it was the code i had.. but then IT services was still showing up when i selected anything else.
    Your logic was saying:

    Did the user select iphone? then, append the $iphone contents to the output.

    Did the user select ipad? then, append the $ipad contents to the output.

    Did the user select ipod? then, append the $ipod contents to the output.

    Is a statement that will always evaluate to true equal to true? then, append the $it contents to the output.

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
  •  
HTML5 Development Center



Recent Articles