Views Count phprunner




<?php
include("include/dbcommon.php");
   $short = $_REQUEST['short'];
 
 
   $sql = "SELECT * FROM url_redirects  WHERE  short='".$short."' LIMIT 1";
$results = CustomQuery($sql);
$data = db_fetch_array($results);

//die($data);



$newViews =  $data['views']+1;


 CustomQuery("update url_redirects set views = ".$newViews." where short='".$short."'");



    if(!empty($data)) {
      header("Location: ".$data['url']."");
    } else {
      $html = "Error: cannot find short URL";
    }
?>

Comments