Hello everyone, learning CRUD with PHP and MySQL. adding new clients, viewing them works fine. however when I select a client to edit the information, it will not update. gives me no errors, just will not update. and all I changed was the the actual sql to UPDATE but im not quite sure where I am messing up. Any help would be greatly appreciated.
[code]<?php require_once('dbcon.php'); ?>
<?php if(isset($_POST['btn_submit'])) { $id = $_POST['txt_client_id']; $client_lname = $_POST['txt_client_lname']; $client_fname = $_POST['txt_client_fname']; $client_mname = $_POST['txt_client_mname']; $client_phone = $_POST['txt_client_phone']; $client_email = $_POST['txt_client_email']; $client_street_address = $_POST['txt_client_street_address']; $client_city = $_POST['txt_client_city']; $client_state = $_POST['txt_client_state']; $client_zip = $_POST['txt_client_zip']; $client_instagram = $_POST['txt_client_instagram']; $client_facebook = $_POST['txt_client_facebook']; if(!empty($client_lname)){ try{ $stmt = $con->prepare("UPDATE client_list set client_lname= :client_lname, client_fname= :client_fname, client_mname= :client_mname, client_phone= :client_phone, client_email= :client_email, client_street_address= :client_street_address, client_city= :client_city, client_state= :client_state, client_zip= :client_zip, client_instagram= :client_instagram, client_facebook= :client_facebook WHERE client_id = :id"); $stmt->execute(array(':client_lname'=>$client_lname, ':client_fname'=>$client_fname, ':client_mname'=>$client_mname, ':client_phone'=>$client_phone, ':client_email'=>$client_email, ':client_street_address'=>$client_street_address, ':client_city'=>$client_city, ':client_state'=>$client_state, ':client_zip'=>$client_zip, ':client_instagram'=>$client_instagram, ':client_facebook'=>$client_facebook, ':id'=>$id)); if($stmt){ header('Location:client_list.php'); } }catch(PDOException $ex){ echo $ex->getMessage(); } }else { echo "INPUT LAST NAME"; } } $client_id = 0; $client_lname = ''; $client_fname = ''; $client_mname = ''; $client_phone = ''; $client_email = ''; $client_street_address = ''; $client_city = ''; $client_state = ''; $client_zip = ''; $client_instagram = ''; $client_facebook = ''; if(isset($_GET['id'])){ $id = $_GET['id']; $stmt = $con->prepare('SELECT * FROM client_list WHERE client_id = :id'); $stmt->execute(array(':id'=>$id)); $row = $stmt->fetch(); $client_id = $row['client_id']; $client_lname = $row['client_lname']; $client_fname = $row['client_fname']; $client_mname = $row['client_mname']; $client_phone = $row['client_phone']; $client_email = $row['client_email']; $client_street_address = $row['client_street_address']; $client_city = $row['client_city']; $client_state = $row['client_state']; $client_zip = $row['client_zip']; $client_instagram = $row['client_instagram']; $client_facebook = $row['client_facebook']; } ?>Edit Client Information
Last Name | |
First Name | |
Middle Name | |
Phone | |
Street Address | |
City | |
State | |
Zip | |