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.
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.
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'];
?>
Of course you can use GET parameters
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)