How to create a friendly URL

Asked

Viewed 119 times

-1

I’m making a business guide website, but when user views the details of this company the URL appears as follows:

www.nomedomeusite/detalhes.php?id_empresa=24

The id_empresa=24 I’m picking up via $_GET['id_empresa'];.

I wonder if it has how to be:

www.nomedomeusite/id_da_empresa/nome_da_empresa.html

This would be the link to access:

<a href="detalhes.php?id_empresa=<?php echo $id_empresa; ?>"><button  type="button">ver detalhes</button></a> 
  • Has https://httpd.apache.org/docs/current/mod/rewrite.html

1 answer

0

Use a session variable as

$_SESSION['id_empresa'] 

or use a form with POST method not to appear on the site

<form action="www.nomedomeusite" method="post">
  <input type="hidden" value="24" name="id_empresa">
  <input type="submit" name="ver detalhes">
</form>

in your link you search id like this

$_POST['id_empresa'];

hope I’ve helped

Browser other questions tagged

You are not signed in. Login or sign up in order to post.