2017-12-26 3 views
0

안녕하세요 나는 LAMP 스택을LAMP 스택 - 404 찾을 수 없음 - PHP

CentOS는 7 아파치 MariaDB PHP 내가 모든 것을 설치하고 내 가상 호스트 및 폴더를 구성

을 구성하려합니다.

테스트 용으로 도메인이 있습니다. example.com

/var/www/example.com/public_html 두 파일이 있습니다.

Index.html을 (기본 페이지)

<!DOCTYPE HTML PUBLIC> 
<html> 
<body> 

<form action="/var/www/example.com/public_html/info.php" method="POST"> 

    Department: <input type="text" name="department"><br><br> 
    Subname: <input type="text" name="Subname"><br><br> 
    lables: <input type="text" name="lables"><br><br> 
    pagerduty: <input type="text" name="pagerduty"><br><br> 
    description: <input type="text" name="description"><br><br> 


    <input type="submit" value="Submit" name="submit"> 

</form> 

</body> 
</html> 

info.php (양식 처리기)

<?php 
$hostname = "localhost"; 
$username = "root"; 
$password = "xxxxxxxxx"; 
$db = "dora"; 
$dbconnect=mysqli_connect($hostname,$username,$password,$db); 
if ($dbconnect->connect_error) { 
die("Database connection failed: " . $dbconnect->connect_error); 
} 
if(isset($_POST['submit'])) { 
$department=$_POST['department']; 
$subname=$_POST['subname']; 
$lables=$_POST['lables']; 
$pagerduty=$_POST['pagerduty']; 
$description=$_POST['description']; 
$query = "INSERT INTO dora (department, subname, lables, pagerduty, description) 
VALUES ('$department', '$subname', '$lables', '$pagerduty', '$description')"; 
if (!mysqli_query($dbconnect, $query)) { 
     die('An error occurred when submitting your review.'); 
    } else { 
    echo "Thanks for your review."; 
    } 
    } 
?> 

http://localhost:80에 가기 - 내 index.html 페이지로드

http://localhost:80/info.php로 이동 - PHP 화면로드

문제는 양식을 작성하고 제출을 클릭하면 info.php을 찾을 수없는 404 오류가 발생합니다. 그것은이 내 처음이 일을한다 등

모든 권한을 작동해야하지만 잘 지침에 따라 ... 어떤 포인터가 좋을 것 같은

내가 뭔가를 놓치고, 모든 보인다.

많은 감사

답변

1

은 양식 조치를하지 공용 HTML 폴더에 상대적인 위치에, 디스크의 위치를 ​​가리키고 있습니다.

변경이 :

또한
<form action="info.php" method="POST"> 

당신의 코드베이스 (예를 들어, 하나에 작은 따옴표를 추가하려고 SQL 인젝션에 취약 명심하십시오 : 이것에

<form action="/var/www/example.com/public_html/info.php" method="POST"> 

폼 입력의).

+0

절대 다이아몬드 선생님, 다음에 양식 동작을 변경해야합니다! 고맙습니다. – user3236169

+0

나는 보안에 대해 더 많이 고려할 것입니다. 지금은 테스트 중이지만 감사합니다! – user3236169

1

당신은

<!DOCTYPE HTML PUBLIC> 
<html> 
<body> 
<form action="info.php" method="POST"> Department: <input type="text" name="department"><br><br> Subname: <input type="text" name="Subname"><br><br> lables: <input type="text" name="lables"><br><br> pagerduty: <input type="text" name="pagerduty"><br><br> description: <input type="text" name="description"><br><br> 
<input type="submit" value="Submit" name="submit"> </form> </body> 

관련 문제