Multiple pages with a different id

Asked

Viewed 223 times

5

I have several PHP pages , with different names of course. I wish I had something like this home.php?id=0, on the following page is named after cliente.php I wish when I have the home opened by clicking on cliente.php in the client menu cliente.php only that the URL appears home.php?id=0.

How can I do this?

  • 1

    This is URL friendly, you should change . htacess or webconfig (depending on which server you use). Don’t you prefer to display only your name? type: www.pagina.client

  • wanted something like www.pagina.com/home.php? id=0 www.pagina.com/home.php? id=1 etc or www.pagina.com/home /www.pagina.com/client

  • 2

    Good morning @Bia doesn’t need mod_rewrite just for this, just client.php being in one include, not that it will be easier to create like this, but in the case of mod_rewrite will often have to rewrite the structure :/

  • I’m using the express Iss

3 answers

3


From what I understand you want to click on the client menu to go to the script cliete.php but that the URL is home.php?id=1.

You can put the URL of the client menu as home.php?id=1:

<a href='home.php?id=1'>Cliente</a> 

And in the script home.php do so:

$id = filter_input(INPUT_GET, 'id');
if($id == 1)
   require('cliente.php');
  • not this url is home.php -> home.php? id=0 , client.php -> home.php? id=1 is what I want to have a file with the menus

  • @user2964140 see my edition. If it is not that you have to explain better.

  • 1

    yes it is that friend worked thank you ;)

2

Change your webconfig to hide the . php extension, notice when I say hide is just hide the . php:

<?xml version="1.0" encoding="UTF-8"?>
   <configuration>
    <system.webServer>
    <rewrite>
    <rules>
    <rule name="exemplo 1" stopProcessing="true">
    <conditions>
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
    <match url="^(.*)$" ignoreCase="true" />
    <action type="Rewrite" url="index.php?url={R:1}" appendQueryString="true" />
    </rule>
    </rules>
    </rewrite>
    </system.webServer>
 </configuration>
  • I tried to do it but it didn’t work

  • @user2964140 let me see your webconfig

  • @user2964140 you tried to access www.pagina.com/client which error gave?

  • no page appears

  • 404 - File or directory not found. The page you are looking for may have been removed, the name may have changed or may be temporarily unavailable.

-1

Just put the link together with the variable GET example:

<a href='home.php?id=<?php echo $id; ?>'>Tal cliente</a>

and do a validation to bring the client.php

Browser other questions tagged

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