checkbox with php

Hi there,

Well i have a registration page with the following two tables, the “About you” table and the “Invoice” table, and then underneath i have a checkbox. In the “About you” table you fill in your details, what i need to know is, how do i make it possible that if you click the checkbox, then the same details that is displayed in the “About you” table is displayed in the “Invoice” table. Thanks in advance. 8)

Heres the code:

[php]<?
// now we insert it into the database
$insert = “INSERT INTO users (user_company, user_address, user_title, user_firstname, user_lastname, user_job, user_tel, user_fax, user_email, user_inv_title, user_inv_firstname, user_inv_lastname, user_inv_job, user_inv_tel, user_inv_fax, user_inv_email, user_inv_address)
VALUES (’”.$_POST[‘user_company’]."’, ‘".$_POST[‘user_address’]."’, ‘".$_POST[‘user_title’]."’, ‘".$_POST[‘user_firstname’]."’, ‘".$_POST[‘user_lastname’]."’, ‘".$_POST[‘user_job’]."’, ‘".$_POST[‘user_tel’]."’, ‘".$_POST[‘user_fax’]."’, ‘".$_POST[‘user_email’]."’, ‘".$_POST[‘user_inv_title’]."’, ‘".$_POST[‘user_inv_firstname’]."’, ‘".$_POST[‘user_inv_lastname’]."’, ‘".$_POST[‘user_inv_job’]."’, ‘".$_POST[‘user_inv_tel’]."’, ‘".$_POST[‘user_inv_fax’]."’, ‘".$_POST[‘user_inv_email’]."’, ‘".$_POST[‘user_inv_address’]."’)";
$add_member = mysql_query($insert);
?>

        <!-- About You -->
        <h4 align="Left"><b><u>About you</u></b></h4>
        <table border="0" width="350">
        <tr><td>Title:</td><td>
          <input type="text" name="user_title" maxlength="10">
        </td></tr>
        <tr><td>First Name:</td><td>
          <input type="text" name="user_firstname" maxlength="40">
        </td></tr>
        <tr><td>Last Name:</td><td>
          <input type="text" name="user_lastname" maxlength="40">
        </td></tr>
        <tr><td>Job Title:</td><td>
          <input type="text" name="user_job" maxlength="60">
        </td></tr>
        <tr><td>Telephone:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td>
          <input type="text" name="user_tel" maxlength="20">
        </td></tr>
        <tr><td>Fax:</td><td>
          <input type="text" name="user_fax" maxlength="20">
        </td></tr>
        <tr><td>Email:</td><td>
          <input type="text" name="user_email" maxlength="50">
        </td></tr>
        </table>
      </td>
    </tr>

    <tr>
      <td rowspan="2" width="350" valign="top" cellpadding="2" cellpaddingcolor="c4c4c4">
        <!--  Invoicing Contact Details -->
        <h4 align="Left"><b><u>Invoicing contact details</u></b></h4>
        <table border="0" width="350">
        <tr><td>Title:</td><td>
        <input type="text" name="user_inv_title" maxlength="10">
        </td></tr>
        <tr><td>First Name:</td><td>
        <input type="text" name="user_inv_firstname" maxlength="40">
        </td></tr>
        <tr><td>Last Name:</td><td>
        <input type="text" name="user_inv_lastname" maxlength="40">
        </td></tr>
        <tr><td>Job Title:</td><td>
        <input type="text" name="user_inv_job" maxlength="60">
        </td></tr>
        <tr><td>Telephone:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        &nbsp;</td><td>
        <input type="text" name="user_inv_tel" maxlength="20">
        </td></tr>
        <tr><td>Fax:</td><td>
        <input type="text" name="user_inv_fax" maxlength="20">
        </td></tr>
        <tr><td>Email:</td><td>
        <input type="text" name="user_inv_email" maxlength="50">
        </td></tr>
        </table><br>

        <input type="checkbox" name="Same_as_you">Check the box if the same as you<br><br>[/php]

EDIT: Topic moved to Beginners Forum, added [php] tags for readability.

If I get it right, it’s a control flow issue:

if (checkbox_checked) { showDataInInvoiceTable(); } else { showDataInAboutYouTable(); }

In pseudocode :wink:

Well i now im confused with what you just told me :-?

Well, the code is pretty staightforward. Google a bit for PHP control flow structures, or try the PHP manual to get up-to-speed on them (coz your questions tell me you aren’t).

But now I understand what you mean! You can do that through a page refresh through PHP, or on-the-fly through Javascript (or perhaps AJAX, but I know nothing about that).

Sponsor our Newsletter | Privacy Policy | Terms of Service