Jump to content

HTML button does not execute PHP section


tiger98_adny

Recommended Posts

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

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

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" 
    <script 
    <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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.