Esempio n. 1
0
function displayAccountForm($status, $us_state_abbrevs, $relationships)
{
    $notice = "";
    if ($status == "success") {
        $notice = "<div class='alert alert-success alert-dismissable'>\n                                                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>\n                                                Account and emergency contact information updated.\n                                            </div>";
    } elseif ($status == "fail") {
        $notice = "<div class='alert alert-danger alert-dismissable'>\n                                                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>\n                                                Account information not updated. Please choose a different email address.\n                                            </div>";
    } elseif ($status == "tech_diff") {
        $notice = "<div class='alert alert-danger alert-dismissable'>\n                                                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>\n                                                There was a problem updating the account information. Please try again.\n                                            </div>";
    }
    try {
        $connection = new PDO("mysql:host=" . DB_HOST_NAME . ";dbname=" . DB_NAME . ";charset=utf8", DB_USER_NAME, DB_PASSWORD);
        // Exceptions fire when occur
        $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $accountInformationQuery = $connection->query('
                                            SELECT M.MEMBER_ID, M.MEMBER_EMAIL, M.FIRSTNAME, M.LASTNAME, M.ADDRESS, M.CITY, M.STATE, M.ZIP, M.PHONE, M.NOTES, M.ADMIN_NOTES, M.PASSWORD, M.DUEDATE, M.ACTIVESTATUS, ME.FIRSTNAME, ME.LASTNAME, ME.PHONE, ME.RELATIONSHIP, ME.EMERGENCY_CONTACT_ID 
                                            FROM ' . USER_CREDENTIAL_TABLE . ' M INNER JOIN ' . EMERGENCY_CONTACTS_TABLE . ' ME ON ME.MEMBER_ID = M.MEMBER_ID
                                            WHERE M.MEMBER_ID = ' . $connection->quote($_POST["buttonMemberID"]));
        $accountInformation = $accountInformationQuery->fetch(PDO::FETCH_NUM);
        echo "<form action='edit.php' method='post'>\n                                                <h3> Editing " . $accountInformation[2] . " " . $accountInformation[3] . "</h3></br>" . $notice . "<input type='text' name='buttonMemberID' value='" . $_POST["buttonMemberID"] . "' hidden>\n                                                <table style='width:75%'>\n                                                    <tr>\n                                                        <td>First Name: <input type='text' name='fname' value='" . htmlentities($accountInformation[2], ENT_QUOTES) . "' required /></td>\n                                                        <td>Last Name: <input type='text' name='lname' value='" . htmlentities($accountInformation[3], ENT_QUOTES) . "'  required /></td>\n                                                        <td>Dues Paid Until: <input type='date' name='duedate' value='" . $accountInformation[12] . "' placeholder='YYYY-MM-DD' required /></td>\n                                                        <td>Member Status: <select name='status' >\n                                                            <option value='active'>Active</option>\n                                                            <option value='inactive'";
        if ($accountInformation[13] == '0') {
            echo "selected>Inactive</option> </select> </td></tr>";
        } else {
            echo ">Inactive</option> </select> </td></tr>";
        }
        echo "<tr>\n                                                            <td> </br>Street Address: <input type='text' name='address' value='" . htmlentities($accountInformation[4], ENT_QUOTES) . "'  required></td>\n                                                            <td></br>City: <input type='text' name='city' value='" . htmlentities($accountInformation[5], ENT_QUOTES) . "' required></td>\n                                                            <td>\n                                                                </br>State: \n                                                                <select name='state' required>" . createStateAbbrevOptions($us_state_abbrevs, $accountInformation[6]) . "</select>\n                                                            </td>\n                                                            <td></br>Zip Code: <input type='text' name='zip' value='" . $accountInformation[7] . "' required /></td>\n                                                        </tr>\n                                                        <tr>\n                                                            <td> </br>Phone Number: <input type='text' name='phone' value='" . preg_replace('/^(\\d{3})(\\d{3})(\\d{4})$/', '$1-$2-$3', $accountInformation[8]) . "' pattern='(?:\\(\\d{3}\\)|\\d{3})[- ]?\\d{3}[- ]?\\d{4}' maxlength='14' required/></td>\n                                                            <td></br>Email Address: <input type='text' name='email' value='" . htmlentities($accountInformation[1], ENT_QUOTES) . "' required></td>\n                                                        </tr>\n                                                    </table>\n                                                    <br />\n                                                    <div style='width:50%'>\n                                                        Member Viewable Notes:</br> \n                                                        <textarea rows='4' cols='100' name='notes'>" . htmlentities($accountInformation[9], ENT_QUOTES) . "</textarea>\n                                                    </div>\n                                                    <div style='width:50%'>\n                                                        Administrator Notes:</br>\n                                                        <textarea rows='4' cols='100' name='adminnotes'>" . htmlentities($accountInformation[10], ENT_QUOTES) . "</textarea>\n                                                    </div>\n                                                    <hr />\n                                                    <h4>Emergency Contact</h4>\n                                                    <table style='width:50%'>\n                                                        <tr>\n                                                                <td>First Name: <input type='text' name='emergency_fname' value='" . htmlentities($accountInformation[14], ENT_QUOTES) . "' required /></td>\n                                                                <td>Last Name: <input type='text' name='emergency_lname' value='" . htmlentities($accountInformation[15], ENT_QUOTES) . "'  required /></td>\n                                                                <td>Phone Number: <input type='text' name='emergency_phone' value='" . preg_replace('/^(\\d{3})(\\d{3})(\\d{4})$/', '$1-$2-$3', $accountInformation[16]) . "' pattern='(?:\\(\\d{3}\\)|\\d{3})[- ]?\\d{3}[- ]?\\d{4}' maxlength='14' required/></td>\n                                                                <td>Relationship <select name='emergency_relationship'>" . createRelationshipsOptions($relationships, $accountInformation[17]) . "</select></td>\n                                                        </tr>\n                                                    </table>\n                                                    <hr />";
    } catch (PDOException $e) {
        echo "\n                                        <div>\n                                            Error: " . $e->getMessage() . "</div>";
    }
}
Esempio n. 2
0
function displayForm($status, $us_state_abbrevs)
{
    $message;
    if ($status == "success") {
        $message = "<div class='alert alert-dismissible alert-success'>\r\n                                            <button type='button' class='close' data-dismiss='alert'>&times;</button>\r\n                                            Event successfully updated.\r\n                                        </div>";
    } elseif ($status == "fail") {
        $message = "<div class='alert alert-dismissible alert-danger'>\r\n                                            <button type='button' class='close' data-dismiss='alert'>&times;</button>\r\n                                            There was a problem updating the event. Please try again.\r\n                                        </div>";
    }
    try {
        $connection = new PDO("mysql:host=" . DB_HOST_NAME . ";dbname=" . DB_NAME . ";charset=utf8", DB_USER_NAME, DB_PASSWORD);
        // Exceptions fire when occur
        $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $formDataQuery = $connection->query('SELECT NAME, DATE, CITY, STATE, ZIP, DESCRIPTION, FORMS 
                                            FROM ' . CALENDAR_TABLE . ' 
                                            WHERE CALENDAR_ID = ' . $connection->quote($_POST["calendarID"]));
        $formData = $formDataQuery->fetch(PDO::FETCH_ASSOC);
        echo '<h3>Editing "' . $formData[NAME] . '"</h3><br />' . $message . "<form action='editEvent.php' method='post'>\r\n                                            <div>\r\n                                                Name: <input type='text' name='name' value='" . htmlentities($formData[NAME], ENT_QUOTES) . "' required />\r\n                                                Date: <input type='date' name='date' placeholder='YYYY-MM-DD' value='" . $formData[DATE] . "' required />\r\n                                            </div><br />\r\n                                            <div>\r\n                                                City: <input type='text' name='city' value='" . htmlentities($formData[CITY], ENT_QUOTES) . "' required />\r\n                                                State:\r\n                                                <select name='state'>" . createStateAbbrevOptions($us_state_abbrevs, $formData[STATE]) . "</select>\r\n                                                Zip Code: <input type='text' name='zip' value='" . htmlentities($formData[ZIP], ENT_QUOTES) . "' required />\r\n                                            </div><br />\r\n                                            <div>\r\n                                                Description:<br /> <textarea rows='4' cols='100' name='description' required>" . htmlentities($formData[DESCRIPTION], ENT_QUOTES) . "</textarea>\r\n                                            </div><br />\r\n                                            <div>\r\n                                                Forms Needed:<br /> <textarea rows='4' cols='100' name='forms' required>" . htmlentities($formData[FORMS], ENT_QUOTES) . "</textarea>\r\n                                            </div>\r\n                                            <br />\r\n                                            <input type='text' name='calendarID' value='" . $_POST["calendarID"] . "' hidden />\r\n                                            <input type='submit' value='Save changes' class='btn btn-default' />\r\n                                        </form><br />";
    } catch (PDOException $e) {
        echo "\r\n                                    <div>\r\n                                        Error: " . $e->getMessage() . "</div>";
        return FALSE;
    }
}
function displayAccountInformation($username, $us_state_abbrevs, $status)
{
    $message = "";
    if ($status == "fail") {
        $message = "<div class='alert alert-dismissible alert-danger'>\r\n                    <button type='button' class='close' data-dismiss='alert'>&times;</button>\r\n                    A technical issue occurred during submission. Please try again.\r\n                </div>";
    }
    if ($status == "fail_email") {
        $message = "<div class='alert alert-dismissible alert-danger'>\r\n                    <button type='button' class='close' data-dismiss='alert'>&times;</button>\r\n                    That email address has already been taken. Please try again with a different email address.\r\n                </div>";
    } elseif ($status == "success") {
        $message = "<div class='alert alert-dismissible alert-success'>\r\n                    <button type='button' class='close' data-dismiss='alert'>&times;</button>\r\n                    Account information successfully saved.\r\n                </div>";
    }
    try {
        $connection = new PDO("mysql:host=" . DB_HOST_NAME . ";dbname=" . DB_NAME . ";charset=utf8", DB_USER_NAME, DB_PASSWORD);
        // Exceptions fire when occur
        $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $accountInformation = $connection->prepare('SELECT FIRSTNAME, LASTNAME, ADDRESS, CITY, STATE, ZIP, PHONE, MEMBER_EMAIL, NOTES FROM ' . USER_CREDENTIAL_TABLE . ' WHERE MEMBER_EMAIL = :username');
        $accountInformation->bindParam(':username', $username);
        $accountInformation->execute();
        $accountInformationResult = $accountInformation->fetch();
        echo '<div class="row-fluid">
                <div class="well bs-component">
                    <form method="post" action="./" id="account_update">
                        <legend style="font-weight: bold; color:#ffffff">ACCOUNT INFORMATION</legend>' . $message . '<div class="form-group row">
                            <label class="col-lg-2 control-label">First name </label>
                            <div class="col-lg-6">
                                <input class="form-control" type="text" name="firstName" value="' . htmlentities($accountInformationResult[0], ENT_QUOTES) . '" required/>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-2 control-label">Last name </label>
                            <div class="col-lg-6">
                                <input class="form-control" type="text" name="lastName" value="' . htmlentities($accountInformationResult[1], ENT_QUOTES) . '" required/>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-2 control-label">Address </label>
                            <div class="col-lg-6">
                                <input class="form-control" type="text" name="address" value="' . htmlentities($accountInformationResult[2], ENT_QUOTES) . '" required/>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-2 control-label">City </label>
                            <div class="col-lg-6">
                                <input class="form-control" type="text" name="city" value="' . htmlentities($accountInformationResult[3], ENT_QUOTES) . '" required/>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-2 control-label">State </label>
                            <div class="col-lg-6">
                                <select class="form-control" name="state">' . createStateAbbrevOptions($us_state_abbrevs, $accountInformationResult[4]) . '</select>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-2 control-label">Zip code </label>
                            <div class="col-lg-6">
                                <input class="form-control" type="number" name="zip" value="' . $accountInformationResult[5] . '" maxlength="5" required/>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-2 control-label">Phone number </label>
                            <div class="col-lg-6">
                                <input class="form-control" type="tel" name="phone" value="' . preg_replace("/^(\\d{3})(\\d{3})(\\d{4})\$/", "\$1-\$2-\$3", $accountInformationResult[6]) . '" pattern="(?:\\(\\d{3}\\)|\\d{3})[- ]?\\d{3}[- ]?\\d{4}" maxlength="14" required/>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-2 control-label">Email </label>
                            <div class="col-lg-6">
                                <input class="form-control" type="email" name="email" value="' . htmlentities($accountInformationResult[7], ENT_QUOTES) . '" required/>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-lg-2 control-label">Notes </label>
                            <div class="col-lg-6">
                                <textarea class="form-control" rows="5" name="notes">' . $accountInformationResult[8] . '</textarea>
                            </div>
                        </div>
                        <div>
                            <input type="hidden" name="submit" value="TRUE">
                            <input type="submit" value="Save changes" class="btn btn-default" />
                        </div>
                    </form>
                </div>
            </div>';
    } catch (PDOException $e) {
        echo "\r\n            <div>\r\n                Error: " . $e->getMessage() . "</div>";
        return FALSE;
    }
}
Esempio n. 4
0
function displayForm($status, $us_state_abbrevs, $submittedName, $submittedDate, $submittedCity, $submittedState, $submittedZip, $submittedDescription, $submittedForms)
{
    $message;
    if ($status == "success") {
        $message = "<div class='alert alert-dismissible alert-success'>\r\n                                            <button type='button' class='close' data-dismiss='alert'>&times;</button>\r\n                                            Event successfully submitted.\r\n                                        </div>";
    } elseif ($status == "fail") {
        $message = "<div class='alert alert-dismissible alert-danger'>\r\n                                            <button type='button' class='close' data-dismiss='alert'>&times;</button>\r\n                                            There was a problem submitting the event. Please try again.\r\n                                        </div>";
    }
    echo "<h3>Add Event</h3>" . $message . "<form action='addEvent.php' method='post'>\r\n                                        <div>\r\n                                            Name: <input type='text' name='name' value='" . htmlentities($submittedName, ENT_QUOTES) . "' required />\r\n                                            Date: <input type='date' name='date' placeholder='YYYY-MM-DD' value='" . $submittedDate . "' required />\r\n                                        </div><br />\r\n                                        <div>\r\n                                            City: <input type='text' name='city' value='" . htmlentities($submittedCity, ENT_QUOTES) . "' required />\r\n                                            State:\r\n                                            <select name='state'>" . createStateAbbrevOptions($us_state_abbrevs, $submittedState) . "</select>\r\n                                            Zip Code: <input type='text' name='zip' value='" . htmlentities($submittedZip, ENT_QUOTES) . "' required />\r\n                                        </div><br />\r\n                                        <div>\r\n                                            Description:<br /> <textarea rows='4' cols='100' name='description' required>" . htmlentities($submittedDescription, ENT_QUOTES) . "</textarea>\r\n                                        </div><br />\r\n                                        <div>\r\n                                            Forms Needed:<br /> <textarea rows='4' cols='100' name='forms' required>" . htmlentities($submittedForms, ENT_QUOTES) . "</textarea>\r\n                                        </div>\r\n                                        <br />\r\n                                        <input type='submit' value='Submit' class='btn btn-default' />\r\n                                    </form><br />";
}
Esempio n. 5
0
function displayForm($us_state_abbrevs, $relationships, $status, $submittedFirstName, $submittedLastName, $submittedDuesDate, $submittedStreet, $submittedCity, $submittedState, $submittedZip, $submittedPhone, $submittedEmail, $submittedAdminNotes, $submittedEmergencyFirstName, $submittedEmergencyLastName, $submittedEmergencyPhone, $submittedEmergencyRelationship)
{
    $notice = "";
    if ($status == "success_manual") {
        $notice = "<div class='alert alert-success alert-dismissable'>\n                                                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>\n                                                User successfully created.\n                                            </div>";
    } elseif ($status == "success_auto") {
        $notice = "<div class='alert alert-success alert-dismissable'>\n                                                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>\n                                                User successfully created. A welcome email with instructions to reset his/her password was sent.\n                                            </div>";
    } elseif ($status == "fail_email") {
        $notice = "<div class='alert alert-danger alert-dismissable'>\n                                                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>\n                                                There was a problem creating this user. Please choose a different email address and try again.\n                                            </div>";
    } elseif ($status == "fail_password") {
        $notice = "<div class='alert alert-danger alert-dismissable'>\n                                                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>\n                                                There was a problem creating this user. Please follow the password requirements and try again.\n                                            </div>";
    } elseif ($status == "tech_diff") {
        $notice = "<div class='alert alert-danger alert-dismissable'>\n                                                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>\n                                                There was a problem creating this user. Please try again.\n                                            </div>";
    }
    echo "<form action='add.php' method='post'>\n                                                <h3> Add a Member</h3></br>" . $notice . "<div>\n                                                    First Name: <input type='text' name='fname' value='" . htmlentities($submittedFirstName, ENT_QUOTES) . "' required />\n                                                    Last Name: <input type='text' name='lname' value='" . htmlentities($submittedLastName, ENT_QUOTES) . "' required />\n                                                    Dues End Date: <input type='date' name='duesdate' placeholder='YYYY-MM-DD' value='" . $submittedDuesDate . "' required />\n                                                </div><br />\n                                                <div>\n                                                    Street Address: <input type='text' name='street' value='" . htmlentities($submittedStreet, ENT_QUOTES) . "' required />\n                                                    City: <input type='text' name='city' value='" . htmlentities($submittedCity, ENT_QUOTES) . "' required />\n                                                    State:\n                                                    <select name='state'>" . createStateAbbrevOptions($us_state_abbrevs, $submittedState) . "</select>\n                                                    Zip Code: <input type='text' name='zip' value='" . htmlentities($submittedZip, ENT_QUOTES) . "' maxlength='5' required />\n                                                </div><br />\n                                                <div>\n                                                    Phone Number: <input type='text' name='phone' value='" . $submittedPhone . "' required />\n                                                    Email Address: <input type='text' name='email' value='" . htmlentities($submittedEmail, ENT_QUOTES) . "' required />\n                                                </div>\n                                                <br />\n                                                <div>\n                                                    Administrator Notes:\n                                                </div>\n                                                <div>\n                                                    <textarea rows='4' cols='100' name='notes'>" . htmlentities($submittedAdminNotes, ENT_QUOTES) . "</textarea>\n                                                </div>\n                                                <hr />\n                                                <h4> Emergency Contact:</h4>\n                                                <div>\n                                                    First Name: <input type='text' name='emergency_fname' value='" . htmlentities($submittedEmergencyFirstName, ENT_QUOTES) . "' required />\n                                                    Last Name: <input type='text' name='emergency_lname' value='" . htmlentities($submittedEmergencyLastName, ENT_QUOTES) . "' required />\n                                                    Phone Number: <input type='text' name='emergency_phone' value='" . htmlentities($submittedEmergencyPhone, ENT_QUOTES) . "' pattern='(?:\\(\\d{3}\\)|\\d{3})[- ]?\\d{3}[- ]?\\d{4}' maxlength='14' required />                                    \n                                                    Relationship:\n                                                    <select name='emergency_relationship'>" . createRelationshipsOptions($relationships, $submittedEmergencyRelationship) . "</select>\n                                            <hr />\n                                            <div>\n                                                <h4>Password</h4>\n                                                <script type='text/javascript'>\n                                                    function ShowHideDiv(generatePassword) {\n                                                        var passwordInformation = document.getElementById('passwordInformation');\n                                                        passwordInformation.style.display = generatePassword.checked ? 'none' : 'block';\n                                                    }\n                                                </script>\n\n                                                <div class='checkbox' for='generatePassword'>\n                                                    <label>\n                                                        <input type='checkbox' name='generatePassword' id='generatePassword' onclick = 'ShowHideDiv(this)' value='TRUE'> Generate password\n                                                    </label>\n                                                </div><br />\n                                                <div id='passwordInformation' style='display: hidden'>\n                                                The user's password must be eight or more characters and have at least one of each:\n                                                <ul>\n                                                    <li>Lower-case letter</li>\n                                                    <li>Upper-case letter</li>\n                                                    <li>Number</li>\n                                                    <li>Special characters</li>\n                                                </ul>\n\n                                                Enter the user's password: <input type='password' name='newPassword1'/><br /><br />\n                                                Re-enter the user's password: <input type='password' name='newPassword2'/><br /><br />\n                                            </div>\n                                            <hr />\n                                            <div>\n                                                <input type='text' name='submit' value='TRUE' hidden>\n                                                <input type='submit' class='btn btn-default' value='Submit' />\n                                            </div>\n                                        </form>";
}