2013-07-28 3 views
-1

나는 데이터베이스에 양식을 보내 데이터베이스와의 연결을했다하지만 난 내 제출 버튼을 사용하는 경우는 말한다 : "

요청 된 URL을 찾을 수 없음/php/GIP/'$ _SERVER ['PHP_SELF ']'이 (가)이 서버에서 발견되지 않았습니다. "

echo '<td><form action=" \' $_SERVER[\'PHP_SELF\'] \' " method="POST" class="Keuze"> 
     <select name="Keuze"> 
     <option>0</option> 
     <option>1</option> 
     <option>2</option> 
     <option>3</option> 
     <option>4</option> 
     <option>5</option> 
     </select> 
     <p><input type="submit" name="submit" value="Bestellen"></p> 
     </form></td>'; 

어떻게 그래서이 문제를 해결 할 그것을 찾을 수 있습니다 나는이 파일이 아닌 다른 파일을 사용하려는 경우 이미 내가 그렇게하는 방법을 작동?

+0

는 결과 HTML에서보세요 다음과 같이 될 것이다이 상황을 처리하는 적절한 방법 - 당신이 실제 PHP 코드가 아닌 평가 값을 삽입하는 것 같습니다. – Lix

+0

당신은 행동에서 직접 URL을 사용하지 말아야합니다. XSS로 이어 지거나 urlencode를 사용할 수 있습니다. – TPSstar

답변

3

당신의 캐릭터 라인 형성과 잘못된 것들을 몇 가지가 가입해야합니다.

action=" \' $_SERVER[\'PHP_SELF\'] \' " 
      ^-----------^---------^---^--- you have escaped the 
terminating single quotes causing the string to not terminate. 
also you have escape the single quotes in key association. also 
you have included the variable inside a single quote block causing the 
variable not to expand. the result is a literal $_SERVER['PHP_SELF'] ' 
being displayed. 

echo '<td><form action="' . $_SERVER['PHP_SELF'] . '" ..... 
+0

이 페이지에서 작동하지만, 다른 페이지로 리디렉션하고 싶다면 'PHP_SELF'대신 무엇을 넣어야합니까? – Jerre44

0
echo '<td><form action=" '. $_SERVER['PHP_SELF'] .' " method="POST" class="Keuze"> 
     <select name="Keuze"> 
     <option>0</option> 
     <option>1</option> 
     <option>2</option> 
     <option>3</option> 
     <option>4</option> 
     <option>5</option> 
     </select> 
     <p><input type="submit" name="submit" value="Bestellen"></p> 
     </form></td>'; 

당신은 문자열

+1

약간의 설명이 여기에 먼 길을 갈 것입니다 ... – Lix

관련 문제