/
home
/
techb158
/
workloadmatch.com
/
Teacher
/
Inc
/
/home/techb158/workloadmatch.com/Teacher/Inc
mkdir
upload
Name
Size
Mode
Actions
Update_Course_Preference.php
13049
0644
edit
dl
rm
Update_Course_Preference_Secretarial.php
5474
0644
edit
dl
rm
Update_Profile.php
4732
0644
edit
dl
rm
Edit:
/home/techb158/workloadmatch.com/Teacher/Inc/Update_Profile.php
(4732B)
<?php include_once '../includes/db_connect.php'; include_once '../includes/psl-config.php'; sec_session_start(); $error_msg = ""; if(isset($_POST["submit"]) && $_POST["submit"]!="") { if (isset ($_POST['username'], $_POST['email'], $_POST['FUserName'], $_POST['LUserName'])) { // $Access_Carrier = $_POST['Access_Carrier']; //$weburl = $_POST['weburl']; $Time_Slot = isset($_POST['Time_Slot']) ? $_POST['Time_Slot'] : []; // Combine time slots into a single string $time_slot_combined = implode(",", $Time_Slot); $FUserNames = $_POST['FUserName']; $LUserNames = $_POST['LUserName']; $Phones =$_POST['Phone']; $rx = "/ (1)?\D* # optional country code (\d{3})?\D* # optional area code (\d{3})\D* # first three (\d{4}) # last four (?:\D+|$) # extension delimiter or EOL (\d*) # optional extension /x"; preg_match($rx, $Phones, $matches); if(!isset($matches[0])) return false; $country = $matches[1]; $area = $matches[2]; $three = $matches[3]; $four = $matches[4]; $ext = $matches[5]; $Phones= $area.''.$three.''.$four; $Access_Carrier= $_POST['Access_Carrier']; if( $Access_Carrier == "") { $Access_Carrier=0; } $Note= $_POST['Note']; $Admin_ID= $_POST['username']; $prof_lang= $_POST['prof_lang']; $email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL); $email = filter_var($email, FILTER_VALIDATE_EMAIL); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { // Not a valid email $error_msg .= '<p class="error">The email address you entered is not valid</p>'; } //$error_msg .= $FUserNames .' '. $Admin_ID .' '. $LUserNames; // $error_msg .= $FUserNames .' '. $random_salt .' '. $LUserNames .' '. $Address .' '. $Phones .' '. $CollegeNames .' '. $Admin_ID .' '. $email .' '. $password ; $user_n=$_SESSION['user_id']; $stmt = $mysqli->prepare('SELECT * FROM teacher_profile WHERE Teacher_ID = ?'); $stmt->bind_param('s', $user_n); $stmt->execute(); $result = $stmt->get_result(); //$row = $result->fetch_assoc(); $count =$result->num_rows; if($count > 0) { if (empty($error_msg)) { $stmt = $mysqli->prepare("UPDATE teacher_profile SET First_Name=?, Last_name=?, Email=?, Phone=?, Time_Slot=?, prof_lang=?, Note=?, SMS_Carrier=? WHERE User_Name=? AND Teacher_ID=?"); $stmt->bind_param('ssssssssss', $FUserNames, $LUserNames, $email, $Phones, $time_slot_combined, $prof_lang, $Note, $Access_Carrier, $Admin_ID, $user_n); if (!$stmt->execute()) { $stmt->close(); set_flash_msg($stmt->error, 'warning'); header('Location: profile.php'); // header('Location: profile.php?error=Client failure to update!'); exit(); }else{ $stmt->close(); set_flash_msg('User is Updated successfully. Thanks!', 'success'); header('Location: profile.php'); exit(); } } } }else { set_flash_msg('all information are required!', 'warning'); header('Location: profile.php'); exit(); } }else if(isset($_POST["submits"]) && $_POST["submits"]!="") { if (isset ($_POST['p'])) { $password = filter_input(INPUT_POST, 'p', FILTER_UNSAFE_RAW); if (strlen($password) != 128) { $error_msg .= '<p class="error">Invalid password configuration.</p>'; } $password = password_hash($password, PASSWORD_BCRYPT); //$error_msg .= $FUserNames .' '. $Admin_ID .' '. $LUserNames; // $error_msg .= $FUserNames .' '. $random_salt .' '. $LUserNames .' '. $Address .' '. $Phones .' '. $CollegeNames .' '. $Admin_ID .' '. $email .' '. $password ; $user_n=$_SESSION['user_id']; $stmt = $mysqli->prepare('SELECT * FROM teacher_profile WHERE Teacher_ID = ?'); $stmt->bind_param('s', $user_n); $stmt->execute(); $result = $stmt->get_result(); $row = $result->fetch_assoc(); $count =$result->num_rows; if($count > 0) { if (empty($error_msg)) { $stmt2 = $mysqli->prepare("UPDATE teacher_profile SET Password=? WHERE User_Name=? AND Teacher_ID=?"); $stmt2->bind_param('sss', $password, $row['User_Name'], $user_n); if (!$stmt2->execute()) { $stmt2->close(); // header('Location: profile.php?error='.$stmt2->error); set_flash_msg('Client password failure to update!', 'warning'); header('Location: profile.php'); exit(); } $stmt2->close(); } set_flash_msg('User password is updated successfully. Thanks!', 'success'); header('Location: profile.php'); exit(); } }else { set_flash_msg('all information are required!', 'warning'); header('Location: profile.php'); exit(); } }
Save
cmd:
run