Advertisement
Guest User

Video script

a guest
Mar 26th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.08 KB | None | 0 0
  1. <html>
  2.     <head>
  3.         <title></title>
  4.  
  5.         <script type="text/javascript" src="jquery.min.js"></script>
  6.         <script type="text/javascript">
  7.             function videoEnded() {
  8.                 //Function called when the video is ended
  9.                 //We add a GET video to call our php function
  10.                 window.location.href = window.location.href+"?video=1";
  11.             }
  12.         </script>
  13.     </head>
  14.  
  15.     <body>
  16.         <?php
  17.             if(isset($_COOKIE["alreadysawvideo"]))
  18.             {
  19.                
  20.                 //If the cookie is already set, then the video has already been saw
  21.                 //So we just redirect the user to the page we want.
  22.                 header("location: http://yoursite.com");
  23.                
  24.             } else if (!empty($_GET['video'])){
  25.                
  26.                 //If the video GET thing is not empty it means the user just saw the video we can redirect him to the website
  27.                 //We add a cookie to remember for the next time that he already saw the video
  28.                 $year = time() + 31536000;
  29.                 setcookie('alreadysawvideo', 1, $year);
  30.                
  31.                 header("location: http://yoursite.com");
  32.             }
  33.         ?>
  34.         <video src="yourvideo.mp4" id="video" controls onended="videoEnded()"></video>
  35.     </body>
  36.  
  37. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement