2017-11-03 2 views
2

리디렉션에 대한 질문이 있습니다. $ _GET을 사용하여 변수를 가져올 수 있도록 일부 매개 변수를 URL에 넣었습니다. 이제 폼을 잘못 채울 때 리디렉션되지만 모든 매개 변수가 누락되어 더 이상 변수에 없습니다. 동일한 매개 변수를 사용하여 동일한 페이지로 리디렉션 할 수있는 방법이 있습니까? 매개 변수

URL : 리디렉션 후 http://localhost:8888/WD2/Week6/Project/flight_bestel.php?stoelnr=5&prijs=99.00&bestemming=Spanje&aankomst=%20Barcelona%20Airport

URL : http://localhost:8888/WD2/Week6/Project/flight_bestel.php

감사 는 enter image description here enter image description here

<?php 
session_start(); 
include_once ("scripts/config.php"); 
include_once ("scripts/api.php"); 

$stoelNr = $_GET['stoelnr']; 
$prijs = $_GET['prijs']; 
$bestemming = $_GET['bestemming']; 
$aankomst = $_GET['aankomst']; 


if($_SERVER['REQUEST_METHOD'] === 'POST') { 

}else{}; 

?> 

<?php require_once('views/shared/_header.inc'); ?> 
<body> 
<header> 
    <?php include('views/shared/_nav.inc'); ?> 
</header> 

<main> 

    <div id="contents" class="container"> 
     <section id="summary"> 

      <form action= "<?php echo $_SERVER['PHP_SELF']; ?>"  method="post" class="form-horizontal"> 

       <div class="form-group"> 
        <div class="col-sm-offset-2 col-sm-10"> 
         <button type="submit" class="btn btn-info"  name="bestel">Bestel nu!</button> 
        </div> 
       </div> 
      </form> 

     </section> 
    </div> 
</main> 
<?php require_once('views/shared/_footer.inc'); ?> 
+0

php 7에서 사용할 수있는 null 병합 사용 http://php.net/manual/en/migration70.new-features.php#migration70.new-features.null-coalesce-op – Krish

+0

필드의 초기 값을 '$ _get (field name)' –

+0

'header()'가 필요하다고 생각합니다. http://php.net/manual/en/function.header.php – akrys

답변

0

그래서 질문은 어떻게 원본을 다시 않는다 "...된다 내 양식에 대한 작업으로 URL "?

한 가지 방법은 쿼리 문자열을 가져 와서 양식 "작업"을 다시 작성하는 것입니다.

뭔가 같은 ... 은 원래의 쿼리 문자열

$query_string = '?'.$_SERVER['QUERY_STRING']; 

를 잡아 양식 조치에 추가하여 퍼즐의 비트에 관해서 가야한다

<form action= "<?php echo $_SERVER['PHP_SELF'] .$query_string; ?>" method="post" class="form-horizontal"> 

당신 노력하고있어.

관련 문제