-2

Just as an example:

http://domain.com/main.php(then the database file here).

I'm not sure what that is even called, but I can't find anything on it.

halfer
  • 19,824
  • 17
  • 99
  • 186
luvUI
  • 19
  • 4

2 Answers2

0

It is not recommended to put your database name in GET requests in the query string for security reasons. But, if you still need it you can do:

http://domain.com/main.php?database_name=MyDatabase

Then on the PHP Code:

<?php
    $databaseName = $_GET['database_name'];
?>
Joel Banzatto
  • 147
  • 2
  • 9
0

Of course you can use GET parameters

http://domain.com/main.php?foo=bar

Which you can get in PHP with:

$_GET['foo'];

I don't really know why you want to pass the database name in the link. Sure, it can be a parameter, but it so unsecure!

UPDATE: you may use more/multiple databases, but use then a config file. The connection names or database names do not passed in the url.

.../main.php?state=demo&type=1, .../main.php?state=demo&type=2, etc.

if ($_GET['state'] == 'demo')
{
    switch ($_GET['type'])
    {
       case 1:
          $databaseName = 'demo_type_1';
       break;
       case 2:
          $databaseName = 'demo_type_2';
       break;
       default:
           throw new Exception('Wrong demo specified');

    }

    // connect to database with the name in $databaseName
}
else
{
   // Other connection
}

Better is to set demo state to session, so you can read out it without the url (more secure)

schellingerht
  • 5,726
  • 2
  • 28
  • 56