# checkbox with php

**URL:** <https://www.phphelp.com/t/checkbox-with-php/9894>\
**Category:** Beginners - Learning PHP\
**Created:** [April 17, 2007, 10:16am UTC](https://www.phphelp.com/t/checkbox-with-php/9894 "2007-04-17T10:16:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![craigbruiners](https://www.phphelp.com/letter_avatar_proxy/v4/letter/c/6f9a4e/32.png) [@craigbruiners](https://www.phphelp.com/u/craigbruiners)\
**Post date:** [April 17, 2007, 10:16am UTC](https://www.phphelp.com/t/checkbox-with-php/9894/1 "2007-04-17T10:16:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Zyppora](https://www.phphelp.com/letter_avatar_proxy/v4/letter/z/76d3ee/32.png) [@Zyppora](https://www.phphelp.com/u/Zyppora)\
**Post date:** [April 17, 2007, 10:35am UTC](https://www.phphelp.com/t/checkbox-with-php/9894/2 "2007-04-17T10:35:03Z")

</div>

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

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

In pseudocode 😉

---

<div class="post-metadata">

**Author:** ![craigbruiners](https://www.phphelp.com/letter_avatar_proxy/v4/letter/c/6f9a4e/32.png) [@craigbruiners](https://www.phphelp.com/u/craigbruiners)\
**Post date:** [April 17, 2007, 10:59am UTC](https://www.phphelp.com/t/checkbox-with-php/9894/3 "2007-04-17T10:59:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Zyppora](https://www.phphelp.com/letter_avatar_proxy/v4/letter/z/76d3ee/32.png) [@Zyppora](https://www.phphelp.com/u/Zyppora)\
**Post date:** [April 17, 2007, 11:14am UTC](https://www.phphelp.com/t/checkbox-with-php/9894/4 "2007-04-17T11:14:02Z")

</div>

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).
