Create a gist now

Instantly share code, notes, and snippets.

Computer Availability status change script
#add your database username and password
#unless the computers name was empty
if($_POST['workstation'] != ""){
$workstation = strtoupper($_POST['workstation']);
else{ #build the computer's name from the host
$host_domain = strstr($_POST['host'], '.');
$workstation = strtoupper(str_replace($host_domain, '', $_POST['host']));
#connect to the database
$DB = mysql_connect('', $user, $password);
@mysql_select_db($database) or die("Unable to select database");
#get the computer's row based on it's name
$checkQuery = "SELECT computer_name FROM compstatus WHERE computer_name = '".$workstation."'";
$result = mysql_query($checkQuery);
#if we find a computer update it's status
$query="UPDATE `compstatus` SET status = '".$_POST['status']."' WHERE computer_name = '".$workstation."'";
mysql_query($query) or die(mysql_error());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment