Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.99 KB | None | 0 0
  1. <script src="jquery.min.js"></script>  
  2. <script type="text/javascript">
  3. $(document).ready(function(){
  4.    
  5.         $("#upload_results").hide();
  6.         $("#simpan").hide();
  7.         $("#ambil_photo").click(function(){
  8.         $("#upload_results").show(500);
  9.         $("#simpan").show(500);
  10.         $("#print_area").hide();
  11.         });
  12.        
  13.        
  14. });    
  15.         </script>
  16.  
  17. </head>
  18. <body bgcolor="#dedede">
  19.     <form name="f_ktm" method="POST">
  20.     <table border="1" style="border:1px; ">
  21.     </tr>
  22.     <tr><td  width="50%" valign="top" align="center">
  23.     <!-- First, include the JPEGCam JavaScript Library -->
  24.     <script type="text/javascript" src="webcam.js"></script>
  25.    
  26.     <!-- Configure a few settings -->
  27.     <script language="JavaScript">
  28.         webcam.set_api_url( 'capture.php' );
  29.         webcam.set_quality( 100 ); // JPEG quality (1 - 100)
  30.         webcam.set_shutter_sound( true ); // play shutter click sound
  31.     </script>
  32.    
  33.     <!-- Next, write the movie to the page at 320x240 -->
  34.     <script language="JavaScript">
  35.         document.write( webcam.get_html(220,300) );
  36.     </script>
  37.    
  38.     <!-- Some buttons for controlling things -->
  39.     <br/><form>
  40.         <input type="button" value="Konfigurasi..." onClick="webcam.configure()">
  41.         &nbsp;&nbsp;
  42.         <input type="button" id="ambil_photo" value="Ambil Photo" onClick="take_snapshot()">
  43.         <input type="submit" id="simpan" name="simpan" value="Simpan" />
  44.     </form>
  45.    
  46.     <!-- Code to handle the server response (see capture.php) -->
  47.     <script language="JavaScript">
  48.         webcam.set_hook( 'onComplete', 'my_completion_handler' );
  49.        
  50.         function take_snapshot() {
  51.             // take snapshot and upload to server
  52.             document.getElementById('upload_results').innerHTML = '<p>Menyimpan photo ...</p>';
  53.             webcam.snap();
  54.         }
  55.        
  56.         function my_completion_handler(msg) {
  57.             // extract URL out of PHP output
  58.             if (msg.match(/(http\:\/\/\S+)/)) {
  59.                 var image_url = RegExp.$1;
  60.                 // show JPEG image in page
  61.                 document.getElementById('upload_results').innerHTML =
  62.                    
  63.                     '<img src="' + image_url + '" border="5">'+
  64.                     '<br/><br/>Lokasi Photo : <input type="text" name="photo_url" value="'+image_url+'" size="65" readonly="readonly">';
  65.                
  66.                 // reset camera for another shot
  67.                 webcam.reset();
  68.             }
  69.             else alert("PHP Error: " + image_url);
  70.         }
  71.     </script>
  72.    
  73.     </td>
  74.     <td valign="top" width="50%" align="center">
  75.         <div id="upload_results" style="background-color:#dedede;"></div>
  76.         <div id="print_area" style="background-color:#dedede;"><?php if(!empty($_GET['last_id'])){
  77.     echo "<iframe src=\"idcard.php?id=$_GET[last_id]\" width=\"500\" height=\"300\" frameborder=\"no\"></iframe>";
  78.     }
  79.     ?>
  80.     </div>
  81.         </td></tr>
  82.     <tr valign="top">
  83.    
  84.     <td>
  85.     <table border="0" width="100%">
  86.    
  87.     <tr valign="top"></tr>
  88.  
  89.     </table>
  90.  
  91. </form>
  92. <?php  
  93. if(!empty($_POST['simpan'])){
  94. include('koneksi.php');
  95. session_start();
  96.  
  97.  
  98. $simpan=mysql_query("insert into foto values('$_SESSION[gae_foto]','$_POST[photo_url]')") or die (mysql_error());
  99. echo("<META HTTP-EQUIV=Refresh CONTENT=\"0.1;URL=index.php?last_id=$_SESSION[gae_foto]\">");
  100.  
  101. }
  102. ?>
  103. </body>
  104. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement