Please log in to access this page.

'; exit(); } else { echo('

You are logged in as ' . $_SESSION['username'] . '. Log out.

'); } // Connect to the database $dbc = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die ('Error connecting to MySQL Server.'); $db = mysql_select_db(DB_NAME, $dbc); if (isset($_POST['submit'])) { // Grab the profile data from the POST $first_name = mysql_real_escape_string(trim($_POST['firstname']), $dbc); $last_name = mysql_real_escape_string(trim($_POST['lastname']), $dbc); $company = mysql_real_escape_string(trim($_POST['company']), $dbc); $address_1 = mysql_real_escape_string(trim($_POST['address_1']), $dbc); $address_2 = mysql_real_escape_string(trim($_POST['address_2']), $dbc); $city = mysql_real_escape_string(trim($_POST['city']), $dbc); $state = mysql_real_escape_string(trim($_POST['state']), $dbc); $zip_code = mysql_real_escape_string(trim($_POST['zip_code']), $dbc); $bs_phone = mysql_real_escape_string(trim($_POST['bs_phone']), $dbc); $email = mysql_real_escape_string(trim($_POST['email']), $dbc); $error = false; // Update the profile data in the database if (!$error) { if (!empty($first_name) && !empty($last_name) && !empty($company) && !empty($address_1) && !empty($city) && !empty($state)&& !empty($zip_code)&& !empty($bs_phone)&& !empty($email)) { // Only set the picture column if there is a new picture if (!empty($new_picture)) { $query = "UPDATE users SET first_name = '$first_name', last_name = '$last_name', company = '$company', address_1 = '$address_1', address_2 = '$address_2', city = '$city', state = '$state', zip_code = '$zip_code', bs_phone = '$bs_phone', email = '$email' WHERE user_id = '" . $_SESSION['user_id'] . "'"; } else { $query = "UPDATE users SET first_name = '$first_name', last_name = '$last_name', company = '$company', address_1 = '$address_1', address_2 = '$address_2', city = '$city', state = '$state', zip_code = '$zip_code', bs_phone = '$bs_phone', email = '$email' WHERE user_id = '" . $_SESSION['user_id'] . "'"; } mysql_query($query, $dbc); // Confirm success with the user echo '

Your profile has been successfully updated. Would you like to view your profile?

'; mysql_close($dbc); exit(); } else { echo '

You must enter all of the profile data.

'; } } // End of check for form submission } else { // Grab the profile data from the database $query = "SELECT first_name, last_name, company, address_1, address_2, city, state, zip_code, bs_phone, email FROM users WHERE user_id = '" . $_SESSION['user_id'] . "'"; $data = mysql_query($query, $dbc); $row = mysql_fetch_array($data); if ($row !=NULL) { $first_name = $row['first_name']; $last_name = $row['last_name']; $company = $row['company']; $address_1 = $row['address_1']; $address_2 = $row['address_2']; $city = $row['city']; $state = $row['state']; $zip_code = $row['zip_code']; $bs_phone = $row['bs_phone']; $email = $row['email']; echo '

* Required field.

'; } else { echo '

There was a problem accessing your profile.

'; } } mysql_close($dbc); ?>
Personal Information