Checkbox Array Question

Discussion in 'PHP' started by caligrafx, Aug 11, 2009.

  1. #1
    Ok so I have this form this I have been working on and can't figure out to this.

    1. How to put the checkbox array in the php form?
    2. If one is select yes and how to send the explanation?

    Here are the code;

    Question 1: html
    <p class="preferredContact">
    							<label>Preferred Contact Method</label>
    							<input type="checkbox" name="email" /><span>Email</span>
    							<input type="checkbox" name="telephone" /><span>Telephone</span>
    						</p>
    Code (markup):
    Question 2: html
    <p class="workingWithRep">
    							<label>Are you currently working with a FDIS representative?</label>
    							<input type="radio" name="no" /><span>No</span> 
    							<input type="radio" name="yes" /><span>Yes-please indicate representative</span>
    							<input type="text" class="repBox" />
    						</p>
    Code (markup):


    Here is the php good I have;
    $Subject = "First Data Online Merchant Inquiry";
    $Business_Type = Trim(stripslashes($_POST['Business_Type'])); 
    $Business_Name = Trim(stripslashes($_POST['Business_Name'])); 
    $Last_Name = Trim(stripslashes($_POST['Last_Name'])); 
    $First_Name = Trim(stripslashes($_POST['First_Name'])); 
    $Address1 = Trim(stripslashes($_POST['Address1'])); 
    $Address2 = Trim(stripslashes($_POST['Address2'])); 
    $City = Trim(stripslashes($_POST['City']));  
    $State = Trim(stripslashes($_POST['State'])); 
    $Zip_Code = Trim(stripslashes($_POST['Zip_Code'])); 
    $Email_Address = Trim(stripslashes($_POST['Email_Address'])); 
    $Day_Phone = Trim(stripslashes($_POST['Day_Phone'])); 
    $Evening_Phone = Trim(stripslashes($_POST['Evening_Phone'])); 
    
    $Interested_In = Trim(stripslashes($_POST['Interested_In'])); 
    $Hear_About_Us = Trim(stripslashes($_POST['Hear_About_Us'])); 
    $State = Trim(stripslashes($_POST['State'])); 
    
    // validation
    $validationOK=true;
    if (!$validationOK) {
      print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
      exit;
    }
    
    // prepare email body text
    $Body = "";
    $Body .= "Business_Type: ";
    $Body .= $Business_Type;
    $Body .= "\n";
    $Body .= "Business_Name: ";
    $Body .= $Business_Name;
    $Body .= "\n";
    $Body .= "Last_Name: ";
    $Body .= $Last_Name;
    $Body .= "\n";
    $Body .= "First_Name: ";
    $Body .= $First_Name;
    $Body .= "\n";
    $Body .= "Address1: ";
    $Body .= $Address1;
    $Body .= "\n";
    $Body .= "Address2: ";
    $Body .= $Address2;
    $Body .= "\n";
    $Body .= "City: ";
    $Body .= $City;
    $Body .= "\n";
    $Body .= "State: ";
    $Body .= $State;
    $Body .= "\n";
    $Body .= "Zip_Code: ";
    $Body .= $Zip_Code;
    $Body .= "\n";
    $Body .= "Email_Address: ";
    $Body .= $Email_Address;
    $Body .= "\n";
    $Body .= "Day_Phone: ";
    $Body .= $Day_Phone;
    $Body .= "\n";
    $Body .= "Evening_Phone: ";
    $Body .= $Evening_Phone;
    $Body .= "\n";
    $Body .= "Interested_In: ";
    $Body .= $Interested_In;
    $Body .= "\n";
    $Body .= "Hear_About_Us: ";
    $Body .= $Hear_About_Us;
    $Body .= "\n";
    
    
    // send email 
    $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
    
    // redirect to success page 
    if ($success){
      print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
    }
    else{
      print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
    }
    Code (markup):

    Again, I have everything working but those to fields. I am still a php rookie and don't even know who to get those to work any help with this would be great.

    Thanks, for your time!
    Adam
     
    caligrafx, Aug 11, 2009 IP
  2. XDMCoder

    XDMCoder Peon

    Messages:
    50
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <input type="radio" name="no" /><span>No</span> 
    <input type="radio" name="yes" /><span>Yes-please indicate representative</span>
    HTML:
    Radio buttons must have radio group:
    <input type="radio" name="QWERTY" value="no" /><span>No</span> 
    <input type="radio" name="QWERTY" value="yes" /><span>Yes-please indicate representative</span>
    HTML:
    Checkboxes must have value too :)
     
    XDMCoder, Aug 11, 2009 IP