Jump to content

Button Menu to run event


praeto

Recommended Posts

This code runs and plays a WAV file whenever someone loads my webcam page.  I would also like to add 3-4 Buttons that when clicked would run the code to different wav files.  (IE WAVE1.WAV or WAVE2.WAV e.t.c.)  What am I missing???

 

(THE BELOW PLAYS ONLY 1 WAV HOWEVER ONLY WHEN PAGE LOADS) --------------------

 

<?php
$runCommand = "sndrec32 /play /close C:\\Windows\\Media\\Notify.wav";
$WshShell = new COM("WScript.Shell");
$output = $WshShell->Exec($runCommand)->StdOut->ReadAll;
echo "<p>$output</p>";
?>

 

 

I TRIED THE FOLLOWING SO USERS COULD CHOOSE WAV TO PLAY

HOWEVER I CANT GET IT TO WORK -------------------------

 

<?php

switch ($_GET['submit']) { 

   case 'Button1': 
   $runCommand = "sndrec32 /play /close C:\\Windows\\Media\\Notify.wav";
   $WshShell = new COM("WScript.Shell");
   $output = $WshShell->Exec($runCommand)->StdOut->ReadAll;
   echo "<p>$output</p>";
   break; 

   case 'Button2': 
   $runCommand = "sndrec32 /play /close C:\\WAVS\\THIS.wav";
   $WshShell = new COM("WScript.Shell");
   $output = $WshShell->Exec($runCommand)->StdOut->ReadAll;
   echo "<p>$output</p>";
   break; 

   case 'Button3': 
   $runCommand = "sndrec32 /play /close C:\\WAVS\\THAT.wav";
   $WshShell = new COM("WScript.Shell");
   $output = $WshShell->Exec($runCommand)->StdOut->ReadAll;
   echo "<p>$output</p>";
   break; 

   default: 
     print ' 
       <form> 
           <input type="submit" name="submit" value="Button1" /> 
           <input type="submit" name="submit" value="Button2" /> 
           <input type="submit" name="submit" value="Button3" /> 
       </form>'; 
     break; 

} // End: switch ($_GET['submit']) 
?>

 

Link to comment
https://forums.phpfreaks.com/topic/75268-button-menu-to-run-event/
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.