Helpful Information
 
 
Category: Client side development
Workstation Name

I am working on an internal site that needs to grab the workstation name in a form that can be passed.

Is this possible?
I have it set up that x.js runs and the data comes up in a popup.
I have no idea how to pass that data. Maybe I'm going down the wrong path.

Pls help

the x.js

var WshNetwork = WScript.CreateObject("WScript.Network");
WScript.echo ("Computer Name = " + WshNetwork.ComputerName);

well, it depends. what do you want to do with this information?

by the way, this ought to be somewhere in the javascript forum.

sorry wrong forum.


I would like to get the info into a form that can be submitted into a sql database.

thanks

Actually, passing info would be in serverside, particularly MySQL forum or PHP :)

Firstly, you are using WSH, (windows scripting host) which can pose a threat to most users, and might be switched off. I assume if you're getting computer name, then its over a corporate internet/intranet so i guess that's a little better

TO do that, here's some code. It utilises PHP and a MySQL Database called info. THe code is fly-typed, so may contain a couple of errors!



<?
if(!$submit)
{
?>
<html>
..
..
<form name="form" method="post" action="<?=$PHP_SELF?>">
<input type="text" name="compname"> Computer Name
<input type="submit" name="submit">
</form>
..
..
</html>
<?
}
else
{
//submit to database
//for this example we'l use database name "info" and table "user"

//first we connect to database

$connect = mysql_connect('localhost','username','password');
mysql_select_db("info",$connect);
$result = mysql_query("INSERT INTO user(compname) VALUES('$compname')");

if($result)
{
echo "Submitted data. Thanks";
}
else
{
echo "An error occured: ".mysql_error();
}

?>


Hope that sheds some light

Jee










privacy (GDPR)