<?php
	session_start();
	include"../../connect/db.php"; 
?>
<?php
	csrf_verify();

	$chap = $_SESSION['chap'];

	if( isset($_POST['f_name']) ){

		$f_name = mysqli_real_escape_string($con,$_POST['f_name']);
		$l_name = mysqli_real_escape_string($con,$_POST['l_name']);
		$phone = mysqli_real_escape_string($con,$_POST['phone']);
		$d_o_b = mysqli_real_escape_string($con,$_POST['d_o_b']);
		$gender = mysqli_real_escape_string($con,$_POST['gender']);
		$address = mysqli_real_escape_string($con,$_POST['address']);
		$city = mysqli_real_escape_string($con,$_POST['city']);
		$state = mysqli_real_escape_string($con,$_POST['state']);
		$zip_code = mysqli_real_escape_string($con,$_POST['zip_code']);


		$sql = mysqli_query($con,"UPDATE users SET f_name = '$f_name', l_name = '$l_name', phone = '$phone', d_o_b = '$d_o_b', gender = '$gender', address = '$address', city = '$city', state = '$state', zip_code = '$zip_code' WHERE email = '$chap'  ");

		if( $sql ){
			echo "success";
		}
		else{
			echo "error";
		}


	}
	else{
		echo "error";
	}

?>