SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    135
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Need help getting "Radio Button Options" to pass through in PHP email form.

    Hello,

    Here is my code of the Form File:

    PHP Code:
    <form action="form_handler.php" method="post" name="form1" id="form1">
          <
    span class="style12"><br>
          <
    strong>A Day of Renewal for Women</strong><br>
          
    Led by the RevJoyce PayneConference evangelist of the South Georgia
          Conference of The United Methodist Church
    .<br>
          <
    br>
          <
    strong>SaturdayApril 4</strong><br>
          
    9:30 a.m.-12:00 noon<br>
          
    Lunch will be served afterwardBring your Bibles! <br>
          <
    br>
    Full Name<br>
    <
    input style="background-color:#D4F3F7;" size="35" id="name" type="text" name="name">
    <
    br>
    <
    br
    Email Address
    <br>
    <
    input style="background-color:#D4F3F7;" size="35" id="email_address" type="text" name="email_address">
    <
    br>
    <
    br
    Special Needs (dietary restrictionswheelchairetc.)
    <
    br>
    <
    input style="background-color:#D4F3F7;" size="35" id="special_needs" type="text" name="special_needs">
    <
    br>
    <
    br
    Staying For Lunch?
    <
    br>
    <
    input value="lunch_Yes" type="radio" name="lunch_yes">
    Yes&nbsp;&nbsp;&nbsp;&nbsp; <br>
    <
    input value="lunch_no" type="radio" name="lunch_no"
     
    No  
     
    <br>
    <
    br>
    <
    br>
    <
    input value="Register Now" id="submit_prayer_request" class="style12Bold" type="submit" name="submit_prayer_request">
          </
    span>
            <
    br>
            <
    br>
        </
    form


    Here is my PHP processing file:

    PHP Code:
    <?php

     $name 
    $_REQUEST['SSN'] ;
     
    $email_address $_REQUEST['FirstName'] ;
     
    $special_needs $_REQUEST['LastName'] ;
     
    $lunch_yes $_REQUEST['MiddleName'] ;
     
    $lunch_no $_REQUEST['email'] ;
     

    header ("Location: thankyou.html");  
    $content = <<<HTML
    <!DOCTYPE html PUBLIC "-//W3C//DTD Xhtml 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <style type="text/css">

    body {
        font-family: Arial;
        font-size: 12px;
    }

    h2 {
        font-family: Georgia;
        font-size: 14px;
        color: blue;
        margin-bottom: 0px;
    }

    H3 {
        font-family: Arial, Helvetica, sans-serif;
        font-size: 14px;
        font-weight: bolder;
        margin-bottom: 5px;
    }

    </style>
    <title>Reservation Form</title>
    </head>



    <body>
    <table width="500px">

        <tr>
            <td>Full Name:</td>
            <td>
    {$name}</td>
        </tr>

        <tr>
            <td>Email Address:</td>
            <td>
    {$email_address}</td>
        </tr>

        <tr>
            <td>Special Needs:</td>
            <td>
    {$special_needs}</td>
        </tr>

        <tr>
            <td>Lunch:</td>
            <td>
    {$lunch_yes} or {$lunch_no}</td>
        </tr>

    </table>
    </body>

    </html>


    HTML;

    mail"email@domain.com""Reservation from Company"$content"From:email@domain.com\r\nMIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n");

    Everything goes through with no problem to my email, except I cannot get the radio buttons that are checked to tell me what it is they checked.

    Thank you!

  2. #2
    SitePoint Addict
    Join Date
    Jul 2008
    Posts
    213
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your lunch radio button names should both be "lunch". Then in your PHP you will
    PHP Code:
    $lunch $_REQUEST['lunch']; 
    Currently you are assign your 2 lunch variables values from different form inputs like Middlename and email. Actually all your variables don't match the field names.

    You should have this:
    PHP Code:
    $name $_REQUEST['name'] ;
    $email_address $_REQUEST['email_address'] ;
    $special_needs $_REQUEST['special_needs'] ;
    $lunch $_REQUEST['lunch'] ; 
    Move your header to after the mail like so:
    PHP Code:
    mail"email@domain.com""Reservation from Company"$content"From:$email_address\r\nMIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n");
    header ("Location: thankyou.html");
    exit; 

  3. #3
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,147
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)
    Are you sure this is working at all?

    The form has the inputs
    • name
    • email_address
    • special_needs
    • lunch_yes
    • lunch_no
    • submit_prayer_request


    (*Because the "lunch" radios have different names, they're checkboxes, not "radio buttons" as you mean them to be.)

    But the code is using
    PHP Code:
    $name $_REQUEST['SSN'] ; 
    $email_address $_REQUEST['FirstName'] ; 
    $special_needs $_REQUEST['LastName'] ; 
    $lunch_yes $_REQUEST['MiddleName'] ; 
    $lunch_no $_REQUEST['email'] ; 
    which might make sense to you but looks totally messed up to me.

    BTW, if you are sending POST do you really want to use REQUEST which would allow someone to type in an HTTP request using GET variables?

  4. #4
    SitePoint Addict
    Join Date
    Jul 2008
    Posts
    213
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ooops.

    PHP Code:
    $name $_POST['name'] ;
    $email_address $_POST['email_address'] ;
    $special_needs $_POST['special_needs'] ;
    $lunch $_POST['lunch'] ; 


Bookmarks

Posting Permissions

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