Location: PHPKode > scripts > PHP Address book > php-address-book_v_1.00_eng/settings.php
<?php 
include_once 'includes/header.inc.php'; 

$userid = $database->escape($_SESSION['userid']);

//submit the form
if(isset($_POST['submit'])){
    $email = $database->escape($_POST['email']);
    $mailinglist = $_POST['mailinglist'];
    
    if($mailinglist == "on"){
        $mailinglist = 1;
    } else {
        $mailinglist = 0;
    }
    
    if($email != ""){
        $database->query("UPDATE `cal_users` SET `email`='$email',`mailinglist`='$mailinglist' WHERE `id` = '$userid'"); 
        ?>
            <div class="alert alert-success">
                The data was saved successfully
            </div>
        <?php
    } else {        
        ?>
            <div class="alert alert-error">
                You must enter an e-mail address
            </div>
        <?php
    }
}

//get user info from database
$query = $database->query("SELECT * FROM `cal_users` WHERE `id` = '$userid'");
while($row = mysql_fetch_assoc($query)){
    $email = $row['email'];
    $mailinglist = $row['mailinglist'];
}

?>
<form class="form-horizontal" method="post" action="">
  <fieldset>
    <legend>Mijn instellingen</legend>
    <div class="control-group">
      <label class="control-label" for="email">E-mail</label>
      <div class="controls">
        <input type="text" class="input-xlarge" id="email" name="email" value="<?php echo $email; ?>">
      </div>
    </div>
    <div class="control-group">
        <label class="control-label" for="mailinglist">Mailinglist</label>
        <div class="controls">
            <label class="checkbox">
            <input type="checkbox" id="mailinglist" name="mailinglist" <?php if($mailinglist == 1){ echo "checked"; } ?> >
            </label>
        </div>
    </div>
    <div class="form-actions">
        <button type="submit" class="btn btn-primary" name="submit">Save</button>
        <button class="btn">Cancel</button>
    </div>
  </fieldset>
</form>

<?php include_once 'includes/footer.inc.php'; ?>
Return current item: PHP Address book