34968-vm/profile.php
Flatlogic Bot 2d8abe32bb V27
2025-10-17 06:23:25 +00:00

100 lines
3.9 KiB
PHP

<?php
session_start();
require_once 'db/config.php';
require_once 'includes/api_keys.php';
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit();
}
include 'header.php';
$user_id = $_SESSION['user_id'];
$db = db();
// Fetch user's data
$stmt = $db->prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$user_id]);
$user = $stmt->fetch();
?>
<div class="container mt-5">
<h2>Account Settings</h2>
<hr>
<form action="profile_update.php" method="POST">
<div class="mb-3">
<label for="email" class="form-label">Email address</label>
<input type="email" class="form-control" id="email" name="email" value="<?php echo htmlspecialchars($user['email']); ?>" required>
</div>
<div class="mb-3">
<label for="phone" class="form-label">Phone Number</label>
<input type="text" class="form-control" id="phone" name="phone" value="<?php echo htmlspecialchars($user['phone_number']); ?>">
</div>
<div class="mb-3">
<label for="password" class="form-label">New Password</label>
<input type="password" class="form-control" id="password" name="password">
<small class="form-text text-muted">Leave blank if you don't want to change it.</small>
</div>
<div class="mb-3">
<label for="password_confirm" class="form-label">Confirm New Password</label>
<input type="password" class="form-control" id="password_confirm" name="password_confirm">
</div>
<hr>
<h4>Location</h4>
<div class="mb-3">
<label for="location_label" class="form-label">Location Label</label>
<input type="text" class="form-control" id="location_label" name="location_label" value="<?php echo htmlspecialchars($user['location_label']); ?>" placeholder="e.g., 'Near Majuro Hospital'">
</div>
<div class="mb-3">
<label for="location_notes" class="form-label">Location Notes</label>
<textarea class="form-control" id="location_notes" name="location_notes" rows="3" placeholder="e.g., 'Red roof building'"><?php echo htmlspecialchars($user['location_notes']); ?></textarea>
</div>
<div id='map' style='width: 100%; height: 400px;'></div>
<input type="hidden" id="lat" name="lat" value="<?php echo htmlspecialchars($user['lat']); ?>">
<input type="hidden" id="lng" name="lng" value="<?php echo htmlspecialchars($user['lng']); ?>">
<hr>
<h4>Payment Methods</h4>
<div class="mb-3">
<p>Connect your payment methods to receive payments.</p>
<a href="#" class="btn btn-primary">Connect with Stripe</a>
<a href="#" class="btn btn-info">Connect with PayPal</a>
</div>
<button type="submit" class="btn btn-primary mt-3">Save Changes</button>
</form>
</div>
<script src='https://api.mapbox.com/mapbox-gl-js/v2.9.1/mapbox-gl.js'></script>
<link href='https://api.mapbox.com/mapbox-gl-js/v2.9.1/mapbox-gl.css' rel='stylesheet' />
<script>
mapboxgl.accessToken = '<?php echo MAPBOX_API_KEY; ?>';
const lat = document.getElementById('lat');
const lng = document.getElementById('lng');
const map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v11',
center: [<?php echo $user['lng'] ? htmlspecialchars($user['lng']) : 171.380; ?>, <?php echo $user['lat'] ? htmlspecialchars($user['lat']) : 7.135; ?>],
zoom: 13
});
let marker = new mapboxgl.Marker()
.setLngLat([<?php echo $user['lng'] ? htmlspecialchars($user['lng']) : 171.380; ?>, <?php echo $user['lat'] ? htmlspecialchars($user['lat']) : 7.135; ?>])
.addTo(map);
map.on('click', (e) => {
const coordinates = e.lngLat;
lat.value = coordinates.lat;
lng.value = coordinates.lng;
marker.setLngLat(coordinates).addTo(map);
});
</script>
<?php include 'footer.php'; ?>