SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member smorelli's Avatar
    Join Date
    Aug 2004
    Location
    kansas city
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript/PHP checkbox array problem

    I have a form that's using javascript checkbox arrays. Upon submitting the form, I am trying to pass the arrays (should do this with form already) to PHP variables.

    I can't figure out how to display the variable of the checkbox arrays on the new page.

    First Page Example:

    <form name='QuoteRequestForm' method='POST' action='page2.php'>
    <table>
    <tr>
    <td align='right' valign='top' class='normal_field'>
    <font face="Arial">AUTO INSURANCE </font>
    </td>
    <td class='element_label'>
    <input type='checkbox' name='AutoInsurance[]' value='Auto_Personal'>Personal Use<br>
    <input type='checkbox' name='AutoInsurance[]' value='Auto_Business'>Business Use<br>
    <input type='checkbox' name='AutoInsurance[]' value='Auto_Recreational'>Recreational Vehicle<br>
    <input type='checkbox' name='AutoInsurance[]' value='Auto_Motorcycle'>Motorcycle<br>
    </td>
    </tr>
    <tr>
    </table>
    </form>


    Page 2 Example:

    <?PHP
    include_once 'Mail.php';
    $recipients = 'someone@somebody.com';
    $headers['From'] = "$FirstName $LastName<$Email>";
    $headers['To'] = 'someone@sombody.com';
    $headers['Subject'] = "Quote Request";
    $todayis = date('l, F j, Y, g:i a') ;
    $body = "$todayis [CST]
    Full Name: $FirstName $LastName";
    Request Info for: $AutoInsurance //Need variable information here
    $params['host'] = 'smtp.somebody.com';
    $params['port'] = '25';
    $params['auth'] = true;
    $params['username'] = 'username';
    $params['password'] = 'password';
    // Create the mail object using the Mail::factory method
    $mail_object =& Mail::factory('smtp', $params);
    $mail_object->send($recipients, $headers, $body);
    echo "<b>$FirstName, your quote request has been sent.</b><b>";
    ?>


    How do I accomplish displaying the array in the $AutoInsurance variable?
    Last edited by smorelli; Aug 19, 2006 at 15:01. Reason: Correction made to original code

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It looks like you have the name and value parameters of the input tags backwards, I think it should be similar to:

    <input type='checkbox' name='AutoInsurance[]' value='Auto_Personal'>

    Fix that and see how it goes.

  3. #3
    SitePoint Member smorelli's Avatar
    Join Date
    Aug 2004
    Location
    kansas city
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oops, it was originally like that and I could not ouput a value other than 'array' on page two. I'm looking for a result that looks a lot like this:

    Full Name: John Doe
    Request Info for: Auto_personal, Auto_Motorcycle


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
  •