function display_form($details = array(), $errors = array()) { global $this_page, $THEUSER, $who, $PAGE; $PAGE->stripe_start(); if (isset($errors["db"])) { $PAGE->error_message($errors["db"]); } else { $URL = new URL("userlogin"); if (!$THEUSER->isloggedin()) { ?> <p>Already joined? <a href="<?php echo $URL->generate(); ?> ">Then log in!</a></p> <?php } } $ACTIONURL = new URL($this_page); $ACTIONURL->reset(); ?> <form method="post" action="<?php echo $ACTIONURL->generate(); ?> "> <?php if ($this_page == "otheruseredit") { ?> <div class="row"> <span class="label">User ID:</span> <span class="formw"><?php echo htmlentities($details["user_id"]); ?> </span> </div> <?php } if ($this_page == 'useredit' && isset($details['status'])) { ?> <div class="row"> <span class="label">Status:</span> <span class="formw"><?php echo htmlentities($details['status']); ?> </span> </div> <?php } if (isset($errors["firstname"])) { $PAGE->error_message($errors["firstname"]); } ?> <div class="row"> <span class="label"><label for="firstname">Your first name:</label></span> <span class="formw"><input type="text" name="firstname" id="firstname" value="<?php if (isset($details["firstname"])) { echo htmlentities($details["firstname"]); } ?> " maxlength="255" size="30" class="form"></span> </div> <?php if (isset($errors["lastname"])) { $PAGE->error_message($errors["lastname"]); } ?> <div class="row"> <span class="label"><label for="lastname">Your last name:</label></span> <span class="formw"><input type="text" name="lastname" id="lastname" value="<?php if (isset($details["lastname"])) { echo htmlentities($details["lastname"]); } ?> " maxlength="255" size="30" class="form"></span> </div> <?php if (isset($errors["email"])) { $PAGE->error_message($errors["email"]); } ?> <div class="row"> <span class="label"><label for="em">Email address:</label></span> <span class="formw"><input type="text" name="em" id="em" value="<?php if (isset($details["email"])) { echo htmlentities($details["email"]); } ?> " maxlength="255" size="30" class="form"></span> </div> <?php if ($this_page == "useredit" || $this_page == "otheruseredit") { // If not, the user's joining. ?> <div class="row"> <br><small>To change <?php echo $who; ?> password enter a new one twice below (otherwise, leave blank).</small> </div> <?php } if (isset($errors["password"])) { $PAGE->error_message($errors["password"]); } ?> <div class="row"> <span class="label"><label for="password">Password:</label></span> <span class="formw"><input type="password" name="password" id="password" value="" maxlength="30" size="20" class="form"> <small>At least six characters</small></span> </div> <?php if (isset($errors["password2"])) { $PAGE->error_message($errors["password2"]); } ?> <div class="row"> <span class="label"><label for="password2">Repeat password:</label></span> <span class="formw"><input type="password" name="password2" id="password2" value="" maxlength="30" size="20" class="form"></span> </div> <br style="clear: left;"> <br> <?php if (isset($errors["postcode"])) { $PAGE->error_message($errors["postcode"]); } ?> <div class="row"> <span class="label"><label for="postcode">Your Australian postcode:</label></span> <span class="formw"><input type="postcode" name="postcode" id="postcode" value="<?php if (isset($details["postcode"])) { echo htmlentities($details["postcode"]); } ?> " maxlength="10" size="10" class="form"> <small>Optional and not public</small></span> </div> <?php if (isset($errors["url"])) { $PAGE->error_message($errors["url"]); } ?> <div class="row"> <span class="label"><label for="url">Your website:</label></span> <span class="formw"><input type="url" name="url" id="url" value="<?php if (isset($details['url'])) { echo htmlentities($details['url']); } ?> " maxlength="255" size="20" class="form"> <small>Optional and public</small></span> </div> <div class="row"> <br>Let other users see <?php echo $who; ?> email address? </div> <?php if (isset($errors["emailpublic"])) { $PAGE->error_message($errors["emailpublic"]); } ?> <div class="row"> <span class="label"> </span> <span class="formw"><input type="radio" name="emailpublic" id="emailpublictrue" value="true"<?php if (isset($details["emailpublic"]) && $details["emailpublic"] == true) { print " checked"; } ?> > <label for="emailpublictrue">Yes</label><br> <input type="radio" name="emailpublic" id="emailpublicfalse" value="false"<?php if ($this_page == "userjoin" && get_http_var("submitted") != "true" || isset($details["emailpublic"]) && $details["emailpublic"] == false) { print " checked"; } ?> > <label for="emailpublicfalse">No</label></span> </div> <div class="row"> <br>Do <?php if ($this_page == "otheruseredit") { echo "they"; } else { echo "you"; } ?> wish to receive occasional update emails about TheyWorkForYou.com? </div> <?php if (isset($errors["optin"])) { $PAGE->error_message($errors["optin"]); } ?> <div class="row"> <span class="label"> </span> <span class="formw"><input type="radio" name="optin" id="optintrue" value="true"<?php if (isset($details["optin"]) && $details["optin"] == true) { print " checked"; } ?> > <label for="optintrue">Yes</label><br> <input type="radio" name="optin" id="optinfalse" value="false"<?php if ($this_page == "userjoin" && get_http_var("submitted") != "true" || isset($details["optin"]) && $details["optin"] == false) { print " checked"; } ?> > <label for="optinfalse">No</label></span> </div> <?php if ($this_page == 'userjoin') { ?> <div class="row"> <br>Would <?php if ($this_page == "otheruseredit") { echo "they"; } else { echo "you"; } ?> like to receive an email whenever your MP does something in Parliament? <br /><small> (if you're already getting email alerts to your address, don't worry about this)</small> </div> <div class="row"> <span class="label"> </span> <span class="formw"><input type="radio" name="mp_alert" id="mp_alerttrue" value="true"<?php if (isset($details["mp_alert"]) && $details["mp_alert"] == true) { print ' checked'; } ?> > <label for="mp_alerttrue">Yes</label><br> <input type="radio" name="mp_alert" id="mp_alertfalse" value="false"<?php if ($this_page == "userjoin" && get_http_var("submitted") != "true" || isset($details["mp_alert"]) && $details["mp_alert"] == false) { print ' checked'; } ?> > <label for="mp_alertfalse">No</label></span> </div> <?php } if ($this_page == "otheruseredit") { if (isset($errors["status"])) { $PAGE->error_message($errors["status"]); } ?> <div class="row"> <span class="label">Security status:</span> <span class="formw"><select name="status"> <?php $USER = new USER(); $statuses = $USER->possible_statuses(); foreach ($statuses as $n => $status) { print "\t<option value=\"{$status}\""; if ($status == $details["status"]) { print " checked"; } print ">{$status}</option>\n"; } ?> </select></span> </div> <div class="row"> <span class="label"><label for="confirmed">Confirmed?</label></span> <span class="formw"><input type="checkbox" name="confirmed[]" id="confirmed" value="true"<?php if (isset($details["confirmed"]) && $details["confirmed"] == true) { print " checked"; } ?> ></span> </div> <div class="row"> <span class="label"><label for="deleted">"Deleted"?</label></span> <span class="formw"><input type="checkbox" name="deleted[]" id="deleted" value="true"<?php if (isset($details["deleted"]) && $details["deleted"] == true) { print " checked"; } ?> > <small>(No data will actually be deleted.)</small></span> </div> <?php } if ($this_page == "useredit" || $this_page == "otheruseredit") { $submittext = "Update details"; } else { $submittext = "Join TheyWorkForYou.com"; } $TERMSURL = new URL('disclaimer'); ?> <div class="row"> <span class="label"> </span> <span class="formw"> <br><small>Read our <a href="<?php echo $TERMSURL->generate(); ?> ">Terms of Use</a>.</small></span> </div> <div class="row"> <span class="label"> </span> <span class="formw"><input type="submit" class="submit" value="<?php echo $submittext; ?> "><!-- this space makes the submit button appear on Mac IE 5! --> </span> </div> <input type="hidden" name="submitted" value="true"> <?php if (get_http_var("ret") != "") { // The user was probably trying to add a writer but is joining first. ?> <input type="hidden" name="ret" value="<?php echo htmlentities(get_http_var("ret")); ?> "> <?php } if (get_http_var("pg") != "") { // So that we get to the right page. ?> <input type="hidden" name="pg" value="<?php echo htmlentities(get_http_var("pg")); ?> "> <?php } if ($this_page == "otheruseredit") { // Need to store the id of the user we're editing. ?> <input type="hidden" name="u" value="<?php echo htmlentities($details["user_id"]); ?> "> <?php } ?> </form> <?php if ($this_page == 'userjoin') { $PAGE->stripe_end(array(array('type' => 'include', 'content' => 'userjoin'))); } else { $PAGE->stripe_end(); } }