Welcome to WebmasterWorld Guest from 22.214.171.124
However, in trying to harvest things like the HTML <title> of my page (to log to my db), or to get variables from HTML <form>, or environmental things like which browser is in use... I'd like to know what would be a good online tutorial or web source to clear the fog here.
Suggestions? Thanks a bunch.
Most of what you are asking is available here
PHP Predefined Variables [ca.php.net]
The superglobal arrays will contain most of what you are looking for.
$_SERVER - user agent, paths, IP and a whole ton more
$_POST - an array of the values posted to the script from a form using the action=POST
$_GET - an array of the values from variables in the url or a form with action=GET
$_COOKIE - variables from cookies
$_ENV - environment vars
and a couple of others.
Using SERVER["REQUEST_URI"], I get "/Filename.php" returned. If I only want "Filename" in a variable (strip the slash and .php), what is a good script or method to do this? I know this is elementary, but I don't want to develop any bad coding habits right at the start.
The URI which was given in order to access this page; for instance, '/index.html'.
which means the data you get will be somewhat unreliable. I would use SCRIPT_NAME
Contains the current script's path. This is useful for pages which need to point to themselves.
The filename of the currently executing script, relative to the document root. For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar would be /test.php/foo.bar.
it really depends on what you want to do with it.
you could use split [ca.php.net] to chop the paths up on the /, which returns an array of the parts and then grab the last part.
To return the last piece you could count [ca.php.net] the elements in the array and use that -1 and then reference the last element.
Now I'm trying to figure out how to hide the userid and password info required to do SQL queries... sure don't want them in the PHP script! Must be more than one way to skin a cat here...
The normal way of doing that is to include() the php code that contains the connection information. For added security, place that php code in a directory that is not accessable from the web. This also means that all the connection information is centrally located, making changes a simple matter of changing one file.
Also, unless the server screws up, any php file is not directly available from the web. It should always be parsed by the server, so the username and password are hidden anyway.