Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
1.1 kB
1
Indexable
Never
<?php
include '../db/connection.php';

$newFname = '';
$newLname = '';
$newgndr = '';
$newconnum = '';
$newaddr = '';

if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['btnsubmit'])) {
$newFname = $_POST['fname'];
$newLname = $_POST['lname'];
$newgndr = $_POST['txtgender'];
$newconnum = $_POST['connum'];
$newaddr = $_POST['addr'];
$newID = $_POST['AcctID'];

$sql = "UPDATE Tbl_Customer SET Fname = ?, Lname = ?, gndr = ?, ConNum = ?, Addr = ? WHERE AcctID = ?";
$params = array($newFname,$newLname,$newgndr,$newconnum,$newaddr,$newID);

$stmt = sqlsrv_query($conn, $sql, $params);

if (!$stmt) {
    die(print_r(sqlsrv_errors(), true));
      echo '<script type="text/javascript">';
      echo 'alert("Incorrect Input");';
      echo 'window.location.href = "addCustomer.php";';
      echo '</script>';
} 
else {

    sqlsrv_close($conn);
           
    echo '<script type="text/javascript">';
    echo 'alert("Added Succesfully");';
    echo 'window.location.href = "customers.php";';
    echo '</script>';
    
    exit();


}

}




?>
Leave a Comment