- Nagios - Switch Interface Traffic
- How To - Linux Server Performance
- Notes - Building New ESXi Host for iSCSI with Jumbo Frames
- Microsoft Office Version Numbers (XP, 2003, 2007, 2010)
- ESXi Custom Welcome Screen Text
- PHP - Read Data from a CSV file
- PHP - Input Variables from URL
- Fix - WMI Error EventID 10
- Fix - EventID 4007 DNS Server Error
- FIX - CHECK_ESX3.PL Script
PHP - Input Variables from URL
- Scripting:
I wanted to be able to generate a small little bit of content based on a variable the user sets. I could have created a small form, but in this case it was easier to pass the variable in a link based on a choice the user selected. Here is a really simple example of passing a variable via URL string to my php page.
if ($_GET["id"]) {
$programID = $_GET["id"];
} else {
$programID = "not specified";
}
echo "Program ID is $programID \n";
It's always important to have cases / defensive / debugging code. Keeps the logs cleaner, makes items easier to fix/debug, and it is just good clean living.
WARNING - I'm not an expert coder/developer, just posting little bits I learn as I go.
UPDATED - Thanks to @j_angliss for providing the more elegant solution. If 'id' in this case is legitimately "0" (zero), then the evaluation would not execute and be treated as false (aka "0"). Try this code instead...
if (array_key_exists('if',$_GET)) {
- MWalker's blog
- Printer-friendly version
- Login to post comments
-
