tiger98_adny Posted April 20, 2017 Share Posted April 20, 2017 Hi Everyone I am new to php so I have a simple HTML button when pushed with username and password should execute php server side. Nothing happens when it pushed. Looking for any guidance here. below is section of webpage i trying to figure out <input type="text" id="tbUsername" class="form-control" placeholder="Username"> </div> <div class="input-group" style="margin-top:20px"> <span class="input-group-addon"><i class="fa fa-lock"></i></span> <input type="password" id="tbPassword" class="form-control" placeholder="Password"> </div> </div> <div class="col-lg-12" style="margin-top: 20px"> <button type="button" class="btn btn-default" id="btnActivate"><i class="fa fa-power-off"></i> Activate Service</button> </div> </div> </div> <?php if (isset($_POST['btnActivate'])) { $path = '\\server\C$\\test\bulk.bat'; $tbPassword = "UserName"; $tbUsername = "Password"; $drive_letter = "Q"; system("net use ".$drive_letter.": \"".$path."\" ".$tbPassword." corp/user:".$tbUsername." /persistent:no>nul 2>&1;"); $location = $drive_letter.":$path"; if ($handle = opendir($location)) { while (false !== ($entry = readdir($handle))) exec("C:\Windows\\System32/cmd.exe $location'"); closedir($handle); } } ?> </body> </html> Link to comment Share on other sites More sharing options...
requinix Posted April 20, 2017 Share Posted April 20, 2017 The way your code is structured suggests you're trying to use a (whose markup isn't included in your post, or judging by the lack of closing doesn't exist at all), which is fine, but your "submit" button is type=button which actually makes it a button that doesn't do anything. It needs to be a type=submit. You know that this will do a net use on the server, right? Not on the client? Link to comment Share on other sites More sharing options...
tiger98_adny Posted April 20, 2017 Author Share Posted April 20, 2017 here is the whole page I should have given everything up front but i did change the type to submit as you suggested and still something is missing. everything has to happen server side <!DOCTYPE html> <html lang="en"> <head> <title>Warehouse - Self Service</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://use.fontawesome.com/d25037cd84.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <div class="row"> <div class="col-lg-12"> <h2 class="page-header"><i class="fa fa-cog"></i> GEO Warehouse / Activate Service</h2> </div> <div class="col-lg-6"> <div class="input-group"> <span class="input-group-addon"><i class="fa fa-user"></i></span> <input type="text" id="tbUsername" class="form-control" placeholder="Username"> </div> <div class="input-group" style="margin-top:20px"> <span class="input-group-addon"><i class="fa fa-lock"></i></span> <input type="password" id="tbPassword" class="form-control" placeholder="Password"> </div> </div> <div class="col-lg-12" style="margin-top: 20px"> <button type="submit" class="btn btn-default" id="btnActivate"><i class="fa fa-power-off"></i> Activate Service</button> </div> </div> </div> <?php if (isset($_POST['btnActivate'])) { $path = '\\server\C$\\test\bulk.bat'; $tbPassword = "UserName"; $tbUsername = "Password"; $drive_letter = "Q"; system("net use ".$drive_letter.": \"".$path."\" ".$tbPassword." corp/user:".$tbUsername." /persistent:no>nul 2>&1;"); $location = $drive_letter.":$path"; if ($handle = opendir($location)) { while (false !== ($entry = readdir($handle))) exec("C:\Windows\\System32/cmd.exe $location'"); closedir($handle); } } ?> } ?> </body> </html> Link to comment Share on other sites More sharing options...
requinix Posted April 20, 2017 Share Posted April 20, 2017 You also need a . And you have to name the inputs. Or switch to AJAX, but that would come with more changes you'd have to make anyways. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.