Advertisement
Guest User

Reload URL

a guest
Mar 24th, 2015
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.55 KB | None | 0 0
  1. <?php
  2.  
  3. if (isset($_POST['example']) && (isset($_POST['actual_position']) && !empty($_POST['actual_position'])) && (isset($_POST['final_position']) && !empty($_POST['final_position']))) {
  4.     $actual_link = 'http://' . $_SERVER['HTTP_HOST'] . '/test.php';
  5.     $actual_link.= '?actual_position=' . $_POST['actual_position'] . '&final_position=' . $_POST['final_position'];
  6.  
  7.     // As you see over the variable $actual_link now contains the name and the values from the HTML input fields.
  8.     //
  9.     // This task could also be done easily by removing this php if condition and replace the HTML form method from POST to GET.
  10.     // The reason I am using this example is just in case you want to extend the link with more data.
  11.     // Maybe you need some data from your database? What do I know?
  12.  
  13.     // Lets add more data to the link
  14.     $actual_link.='&more_data=a_value';
  15.  
  16.     header('Location: ' . $actual_link); return;
  17. }
  18.  
  19. echo '
  20.     <form method="POST">
  21.         <label for="actual_position">
  22.             <span>From: <span class="required"></span></span>
  23.             <input name="actual_position" type="text" maxlength="512" id="actual_position" class="searchField"
  24.                 value="' . (!empty($actual_position) ? $_GET['actual_position'] : '') . '" />
  25.         </label>
  26.  
  27.         <label for="final_position">
  28.             <span>To: <span class="required"></span></span>
  29.             <input name="final_position" type="text" maxlength="512" id="final_position" class="searchField"
  30.                 value="' . (!empty($final_position) ? $_GET['final_position'] : '') . '" />
  31.         </label>
  32.  
  33.         <input type="submit" name="example" value="Start redirect">
  34.     </form>
  35. ';
  36.  
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement