문서 제거 및 데이터베이스 업데이트에 도움이되는 두 개의 파일이 있습니다. 첫 번째 파일은 제거 버튼이있는 양식과 remove()라는 javascript 기능으로 구성됩니다. 두 번째 PHP 페이지는 결과를 반환하지 않는 파일을 제거합니다.문서 제거 및 데이터베이스 업데이트
코드 Remove.php에 대한 (() 함수 제거를 호출시) : 내가 경고 (문서를) 시도 않았다
$Doc=$_GET['Doc']; //Value get from remove() function
$ID= intval($_POST['ID']);
$FirstReport= $_POST['FirstReport'];
$SecReport = $_POST['SecReport'];
$FirstReportPath= $_POST['FirstReportPath'];
$SecReportPath = $_POST['SecReportPath '];
$DB = new PDO('sqlite:/database/Student.db');
//If i click remove firstreport button, i'll check it to see if it's the same
if(($Doc) == ($FirstReport))
{
$result= $DB->query("Update Student set FirstReport='No' WHERE ID=".$ID);
//This unlink should remove the document file from the path.
unlink($FirstReportPath);
echo "success";
}
else
{
//same code repeated as if statement
}
자바 스크립트 기능
function RemoveDoc(Doc)
{
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","functions/Resubmit.php?Doc="+Doc,true);
xmlhttp.send();
document.getElementById("RemoveMsg").innerHTML=xmlhttp.responseText;
return false;
}
을하고 문서 이름은 쇼를 않습니다 그러나 두 번째 remove.php에서는 코딩을 실행하지 않습니다. 시도 "GET"/ "POST"도 같은 결과. 친절하게 조언하십시오.
을 수정할 수 있습니다 당신의 PHP 코드를 누군가가 당신의 서버에 임의의 파일을 제거 할 수있는 그대로. 입력 내용을 확인하는 것을 잊지 마십시오. –
나는 그 폴더로 파일을 옮길 수있다. 하지만 지금은 링크를 끊을 수 없습니다. – JLearner
firstreport와 firstreportpath를 출력하고 공백을 포함하여 동일한 대소 문자, 동일한 길이, 동일한 문자를 사용했는지 확인 했습니까? var_dump를 사용하고 –