unable to find what is the error of PHP update

Wednesday, November 4, 2015

I am working on a web page where a doctor can update patients information, including adding PDF files to his ID row in SQL. When I try to insert new patient data, the file is added to the directory and can be downloaded, but when I click on the update page of a row of a patient, even if I didn't upload a new file because I don't need to change the last file, and then I click on update button and the file path is changed into some unknown format. And when I want to update a patient and add a new file to it, I can't either.
The code is:



<?php 
require_once ('../include/global.php');
$id=$_REQUEST['id'];

if (isset ($_POST['name'])) {
$name = $_POST['name'];
}
if (isset ($_POST['remarcs'])) {
$remarcs = $_POST['remarcs'];
}
if (isset ($_POST['test_res'])) {
$test_res = $_POST['test_res'];
}
if (isset ($_POST['address'])) {
$address = $_POST['address'];
}

if (isset ($_POST['date'])) {
$date = $_POST['date'];
}

if (isset ($_POST['phone_num'])) {
$phone = $_POST['phone_num'];
}

if (isset ($_POST['illness'])) {
$illness = $_POST['illness'];
}
if (isset ($_POST['echo'])) {
$echo = $_POST['echo'];
}
if (isset ($_POST['pe'])) {
$pe = $_POST['pe'];
}
if (isset ($_POST['pmhx'])) {
$pmhx = $_POST['pmhx'];
}
if (isset ($_POST['pshx'])) {
$pshx = $_POST['pshx'];
}
if (isset ($_POST['habbits'])) {
$habbits = $_POST['habbits'];
}
if (isset ($_POST['occup'])) {
$occup = $_POST['occup'];
}
if (isset ($_POST['allergy'])) {
$allergy = $_POST['allergy'];
}

//Check file is uploaded or not

$path = "../uploads/".$_FILES['file']['name'];
//$path2 = "../uploads/".$_FILES['echo_photo']['name'];

//move_uploaded_file($_FILES["file"]["tmp_name"], $path);
$new_path = $path;
$sql="UPDATE $tbl_name SET
name = '$name',
echo_files = '$new_path',
remarcs = '$remarcs',
test_res = '$test_res',
date = '$date',
address = '$address',
phone_num = '$phone',
illness = '$illness',
echo = '$echo',
pmhx = '$pmhx',
pshx = '$pshx',
habbits = '$habbits',
occup = '$occup',
allergy = '$allergy',
pe = '$pe'
WHERE id = ".$id;

$result=mysqli_query($con,$sql) or die('Unable to execute query. '. mysqli_error($con));
if($result){
header("location:../SearchOrView.php");

}
else {
//header("location:update_false.php");
die('Unable to execute query. '. mysqli_error($con));


}
?>

0 comments:

Post a Comment