// Collect the ID we wish to delete $id = $_POST['id']; //delete contact with that ID deleteContact($id); $output['msg'] = "Contact deleted."; // Reload the contacts $output['contacts'] = getContacts(); echo json_encode($output); } else { if ($action == "editName") { // Collect the ID we wish to edit $id = $_POST['pk']; // Get the post variables for the edited name $name = $_POST['value']; // Update name in database editName($name, $id); $output['msg'] = "Contact name updated."; echo json_encode($output); } else { if ($action == "editPhone") { // Collect the ID we wish to edit $id = $_POST['pk']; // Get the post variables for the edited phone number $phone = $_POST['value']; // Update phone number in database editPhone($phone, $id); $output['msg'] = "Contact phone number updated."; echo json_encode($output); } else { $output['contacts'] = getContacts(); $output['msg'] = "List of all contacts";
<?php include_once '/index.php'; include_once '/connectDB.php'; if (isset($_SESSION['msg'])) { echo $_SESSION['msg']; } if (login_check($mysqli)) { if (isset($_POST['editPassword'])) { editPassword($mysqli, $_POST['oldPasswordText'], $_POST['passwordText1'], $_POST['passwordText2']); header('Location: edit_account.php'); } if (isset($_POST['editName'])) { editName($mysqli, $_POST['passwordText'], $_POST['nameText']); header('Location: edit_account.php'); } if (isset($_POST['editAccountName'])) { editAccontName($mysqli, $_POST['passwordText'], $_POST['accountNameText1'], $_POST['accountNameText2']); header('Location: edit_account.php'); } if (isset($_POST['editEmail'])) { editEmail($mysqli, $_POST['passwordText'], $_POST['emailText1'], $_POST['emailText2']); header('Location: edit_account.php'); } echo '<br>Edit Password: <br> <form method=\'post\' action=\'' . htmlspecialchars($_SERVER['PHP_SELF']) . '\'><br> Old Password: <input type=\'password\' name = \'oldPasswordText\' /><br> New Password : <input type=\'password\' name = \'passwordText1\' /><br> New Password again: <input type=\'password\' name = \'passwordText2\' /><br> <input type=\'submit\' name=\'editPassword\' value=\'edit\' /> </form><br><br>'; echo 'Edit Name: <br> <form method=\'post\' action=\'' . htmlspecialchars($_SERVER['PHP_SELF']) . '\'><br>