0

I want to redirect this url localhost.com/page.php?user=editor after submit a form which is form.php page and when submit it will redirect to mentioned url. This url is not fixed it can be changed based on user such as user/editor/admin/superadmin.

Note: I don't know exactly the name of this url parse url or query parameter. Please write me the name of this kind of url.

1 Answers1

0

You can try this code, hopefully, it will work

Pass The $newUri.$parm with your form like-

$parm=$_GET['user'];
  $uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
  $uri = explode( '/', $uri );
 $newUri = $uri[1];
?>
<input type="hidden" name="url" value="<?php echo $newUri.$parm ?>">

Redirect from form.php

<?php
  $url=$_POST['url'];
  echo "<script> 
    window.location.href='.$url.';
  </script>";
?>