83 lines
4.9 KiB
PHP
83 lines
4.9 KiB
PHP
<?php
|
|
require_once('.hta_config/crm_config.php');
|
|
require_once('.htac_header.php');
|
|
require_once('.htac_nav.php');
|
|
$nameLetter = "";
|
|
?>
|
|
<section class="container mx-auto px-4 max-w-2xl rounded-xl mt-10 py-20 shadow-xl">
|
|
<p class="text-[25px] font-bold">Profile</p>
|
|
<div><?php echo $nameLetter; ?></div>
|
|
<form method="post" >
|
|
<?php
|
|
|
|
if($_SERVER['REQUEST_METHOD'] == "POST"){
|
|
$convertPass = md5($_POST['pass']);
|
|
try {
|
|
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
|
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
$stmt = $conn->prepare("UPDATE users SET name = :name, email = :email, pass = :pass WHERE email = :userID");
|
|
$stmt->bindParam(':name', $_POST['name']);
|
|
$stmt->bindParam(':email', $_POST['email']);
|
|
$stmt->bindParam(':pass', $convertPass);
|
|
$stmt->bindParam(':userID', $_SESSION['email']);
|
|
$stmt->execute();
|
|
|
|
echo '<script>window.location.href="/logout"</script>';
|
|
} catch(PDOException $e) {
|
|
echo "Error: " . $e->getMessage();
|
|
}
|
|
};
|
|
try {
|
|
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
|
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
$stmt = $conn->prepare("SELECT * FROM users WHERE email = :email");
|
|
$stmt->bindParam(':email', $_SESSION['email']);
|
|
$stmt->execute();
|
|
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
foreach($rows as $row){
|
|
$nameParts = explode(" ", $row['name']);
|
|
$firstInitial = substr($nameParts[0], 0, 1);
|
|
$lastInitial = substr($nameParts[count($nameParts) - 1], 0, 1);
|
|
$nameLetter = $firstInitial.$lastInitial;
|
|
?>
|
|
<div class="flex justify-center text-[60px] font-bold" >
|
|
<p class="mb-20 uppercase" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); color: #fff; border-radius: 6px; padding: 15px 20px 15px 20px; border-radius: 50%;"><?php echo $nameLetter; ?></p>
|
|
</div>
|
|
<div class="grid grid-cols-2 gap-6">
|
|
<div class="flex flex-col">
|
|
<label for="name">Name:</label>
|
|
<input type="text" name="name" id="" value="<?php echo $row['name']; ?>" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;">
|
|
</div>
|
|
<div class="flex flex-col">
|
|
<label for="name">Email:</label>
|
|
<input type="text" name="email" id="" value="<?php echo $row['email']; ?>" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;">
|
|
</div>
|
|
<div class="flex flex-col">
|
|
<label for="name">Mobile:</label>
|
|
<input type="text" name="mobile" id="" value="<?php echo $row['mobile']; ?>" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;">
|
|
</div>
|
|
<div class="flex flex-col">
|
|
<label for="name">Access State:</label>
|
|
<p style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;" ><?php echo $row['states']; ?></p>
|
|
</div>
|
|
<div class="flex flex-col">
|
|
<label for="name">Access Business Verticals:</label>
|
|
<p style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;" ><?php echo $row['access']; ?></p>
|
|
</div>
|
|
<div class="flex flex-col">
|
|
<label for="name">Password:</label>
|
|
<input type="password" name="pass" id="" style="border: 1px solid #D9D9D9; border-radius: 5px; padding: 6px;">
|
|
</div>
|
|
</div>
|
|
<?php
|
|
}
|
|
} catch (PDOException $e) {
|
|
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
|
};
|
|
?>
|
|
|
|
|
|
<input class="mt-10 float-right" type="submit" value="Update Profile" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); color: #fff; border-radius: 6px; padding: 6px 20px 6px 20px;">
|
|
</form>
|
|
<p class="text-center font-bold text-[#FB5555] mt-10">if change profile information then login again</p>
|
|
</section>
|