jomin_george94 jomin_george94 - 3 months ago 12
HTML Question

PHP how to redirect the page to a different PHP file?

I couldn't find much help while I was looking for my answer that's the reason for the question on here.

Basically I have this bit of code :

<a href="manage/10000' . $user["user_id"] . ' " class="user_grop">More Info</span></a>

now how is it possible to get what I am passing ?

Do I make a php file called manage.php ? if so what makes it so that it looks at manage.php ? and then get it through $_GET but how is it possible ?

I am not sure how to go about it so I would appreciate any of yours suggestions.



Your problem can have two possible solutions:

  1. By creating manage.php file and passing query string to it.

Your code for the link will like this:

<a href="manage.php?user_id=' . $user["user_id"] . ' " class="user_grop">More Info</span></a>

Now on manage.php page, you can access user_id like this:

<?php $user_id = $_GET["user_id"]; ?>
  1. Using .htaccess, create .htaccess file and put the code below in it. .htaccess file must be placed in same dir where your index.php file is.

    <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [L] </IfModule>

Now you can access your query strings on index.php file using $_SERVER['REQUEST_URI'] global variable.

<a href="manage/10000/' . $user["user_id"] . ' " class="user_grop">More Info</span></a>

Your link to access page must look like above note the / after 10000 else user_id will get merge with 10000