77 lines
4.1 KiB
PHP
77 lines
4.1 KiB
PHP
<?php
|
|
require_once('.hta_config/crm_config.php');
|
|
require_once('.htac_header.php');
|
|
require_once('.htac_nav.php');
|
|
|
|
if( $_SERVER['REQUEST_METHOD']=="POST" && isset($_POST['bverticals']) && isset($_POST['formname']) && isset($_POST['form_id']) ){
|
|
try {
|
|
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
|
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
$stmt = $conn->prepare("UPDATE addforms SET formname = :formname, bverticals = :bverticals WHERE id = :id");
|
|
$stmt->bindParam(':formname', $_POST['formname']);
|
|
$stmt->bindParam(':bverticals', $_POST['bverticals']);
|
|
$stmt->bindParam(':id', $_POST['form_id']);
|
|
$stmt->execute();
|
|
|
|
echo '<script> window.location.assign("/admin/add-forms") </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 business_verticals");
|
|
$stmt->execute();
|
|
$verticals_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
// foreach($verticals_data as $verticals){
|
|
// $bverticals = $verticals['bv'];
|
|
// }
|
|
|
|
} catch (PDOException $e) {
|
|
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
|
}
|
|
|
|
try {
|
|
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
|
|
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
$stmt = $conn->prepare("SELECT * FROM addforms WHERE id=:id");
|
|
$stmt->bindParam(":id", $_GET['id']);
|
|
$stmt->execute();
|
|
$formrows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
foreach($formrows as $formname){ $pre_verticals = $formname['bverticals']; ?>
|
|
<div class="flex flex-col place-items-center mt-40 mb-60">
|
|
<form method="post" class="max-w-2xl shadow-xl p-4 rounded-lg space-y-4" style="width: 100%; max-width: 600px;">
|
|
<p class="my-4" style="border-bottom: 2px solid #464E5F; border-style: dashed; font-size: 20px; font-weight: bold" >Edit From</p>
|
|
<div style="display: flex; flex-direction: column;">
|
|
<label for="">Form Name:</label>
|
|
<input type="text" name="form_id" value="<?php echo $formname['id']; ?>">
|
|
<input type="text" name="formname" id="formname" value="<?php echo $formname['formname']; ?>" style="border: 1px solid #363650; border-radius: 5px; padding: 6px;" />
|
|
</div>
|
|
<div style="display: flex; flex-direction: column;">
|
|
<label for=""> Business Verticals:</label>
|
|
<select name="bverticals" style="border: 1px solid #363650; border-radius: 5px; padding: 6px; ">
|
|
<option value="Select">Select</option>
|
|
<?php
|
|
foreach($verticals_data as $verticals) {
|
|
$isSelected = in_array($pre_verticals, $verticals) ? 'selected' : '';
|
|
echo '<option value="'.$verticals['bv'].'" '.$isSelected.'>'.$verticals['bv'].'</option>';
|
|
}
|
|
?>
|
|
</select>
|
|
|
|
</div>
|
|
<div class="flex flex-col justify-center">
|
|
<input type="submit" value="Update" id="submit" name="submit" style="background: linear-gradient(90deg, rgba(111, 107, 255, 0.91) 0%, rgba(68, 55, 128, 0.91) 100%); text-align: center; padding: 6px; color: #fff; border-radius: 6px; margin-top: 6px;" />
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<?php
|
|
}
|
|
|
|
} catch (PDOException $e) {
|
|
echo "<p class='text-danger'>Error: " . $e->getMessage() . "</p>";
|
|
}
|
|
|
|
?>
|