Tick box for autocompletion or other method without JavaScript

Hi there,

I have a form (below) whereby a customer enters their delivery and billing address. If they enter a different delivery and billing address then it works fine…it stores $first, $surname, $telephone, $email, $deliveryaddress, $deliverypostcode, $billingaddress, $billingcode, etc.

But if they are the same, I do not want to ask customers to enter their address twice. I have added a tick box in the form below. How do I code it to say 'if the user ticks the box:

$deliveryaddress = $billingaddress
$deliverypostcode = $billingcode

???

I did think about an autocompletion but I DO NOT WANT TO USER ANY JAVASCRIPT - some users disable or do not install it.


<p>Delivery address:</p>
    <p>
    <label for="address1">Address 1:</label>
    <input type="text" name="address1" id="address1" />
    <br />
    <label for="address2">Address 2:</label>
    <input type="text" name="address2" id="address2" />
    <br />
    <label for="address3">Address  3:</label>
    <input type="text" name="address3" id="address3" />
    <br />
    <label for="address4">Address 4:</label>
    <input type="text" name="address4" id="address4" />
    <br />
    <label for="city">City:</label>
    <input type="text" name="City" id="city" />
    <br />
    <label for="county">County:</label>
    <input type="text" name="county" id="county" />
    <br />
    <label class="postcode" for="postcode">Post code:</label>
    <input type="text" name="postcode" id="postcode" />
    <br />
    
    </p>
    <p>Tick this box if the billing address is the same as the delivery address.
  <input name="billingsame" type="checkbox" value="yes">                     
      
    </p>
<p>Billing address:</p>
    <label for="billaddress1">Billing Address 1:</label>
    <input type="text" name="billaddress1" id="billaddress1" />
    <br />
    <label for="billaddress2">Billing Address 2:</label>
    <input type="text" name="billaddress2" id="billaddress2" />
    <br />
    <label for="billaddress3">Billing Address  3:</label>
    <input type="text" name="billaddress3" id="billaddress3" />
    <br />
    <label for="billaddress4">Billing Address 4:</label>
    <input type="text" name="billaddress4" id="billaddress4" />
    <br />
    <label for="billcity">City:</label>
    <input type="text" name="billCity" id="billcity" />
    <br />
    <label for="billcounty">County:</label>
    <input type="text" name="billcounty" id="billcounty" />
    <br />
    <label class="billpostcode" for="postcode">Post code:</label>
    <input type="text" name="billpostcode" id="billpostcode" />
    <br />

Hope you can help,

Matt.

Already answered here.

In your form handler, prior to storing in the database but before any validation/security you are doing …



if( isset($_POST['billingsame']) ){

// reassign delivery address to billing address
$_POST['billaddress1'] = $_POST['address1'] ;
... etc


}

// from hereon, as normal ...

If you want to see for yourself the difference between the checkbox being set or not, just add

var_dump($_POST);

to the top of your form handler.

Edit:

Oh, right, already answered …