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> Quote Link to comment https://forums.phpfreaks.com/topic/303759-html-button-does-not-execute-php-section/ 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? Quote Link to comment https://forums.phpfreaks.com/topic/303759-html-button-does-not-execute-php-section/#findComment-1545671 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> Quote Link to comment https://forums.phpfreaks.com/topic/303759-html-button-does-not-execute-php-section/#findComment-1545675 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. Quote Link to comment https://forums.phpfreaks.com/topic/303759-html-button-does-not-execute-php-section/#findComment-1545677 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
× Pasted as rich text. Restore formatting
Only 75 emoji are allowed.
× Your link has been automatically embedded. Display as a link instead
× Your previous content has been restored. Clear editor
× You cannot paste images directly. Upload or insert images from URL.