Hey friends i just wanna know how can we change the url like if i have a index page now i want to include the login page on click to a link now the url should be index.php?action=login

You have to use switch() inside your index.php, an example:

<?php
$action = $_GET['action'];
switch($action) {
    case 'login':
    # code for login page
    break;
    case 'index':
    default:
    # code for home page
}
?>

http://php.net/manual/en/control-structures.switch.php

i am using the swith case but when i am trying to insert some values its not inserting into the database.

Maybe I did not understand your question, can you paste the code?

let me explain my question I have to create a index page in php now in index page i have multiple links like login, registration,view products,add products in the side bar.
i just want to know when a user clicks on login then url should be like index.php?subject=login or if he clicks on add category index.php?subject=category and the pages according to the url changes will be displayed.

Member Avatar for diafol

So what you're saying is there is only index.php and that you're changing the served content based on the url parameter 'subject'. I assume you're using include files for this?

if(isset($_GET['subject']) && file_exists('templates/' . basename($_GET['subject']).'php')){
  include('templates/' . basename($_GET['subject']).'php');
}else{
  include('templates/index.php');
}

Not tested.

Thanks Ardav for the help and one more thing is that when i am adding any category to the database it throws me to the again index.php though i have put the action to the list.php

Member Avatar for diafol

Could you show the code that you're using for this and the url that's appearing?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.