PHP command???!?

Discussion in 'PHP' started by Majo0od, Nov 8, 2009.

  1. #1
    Hey guys,
    Is there a php command that allows when a person goes to a certain page, it executes a function? Would that be exec(); function?

    Thanks,
    Majo0od
     
    Majo0od, Nov 8, 2009 IP
  2. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #2
    Executes what function ?? atleast tell us that
     
    Bohra, Nov 8, 2009 IP
  3. Obulus

    Obulus Peon

    Messages:
    85
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Surely just placing the code you want executed on the page they go to, would be the most efficient way?
     
    Obulus, Nov 8, 2009 IP
  4. Sky AK47

    Sky AK47 Member

    Messages:
    298
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    45
    #4
    if($page=='this'){
    exeCuteThisShit(); //?
    }
    PHP:
    Would be cool if you gave more information.
     
    Sky AK47, Nov 8, 2009 IP
    ShadyStudent likes this.
  5. Majo0od

    Majo0od Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    well im creating a view counter, and trying to make it unique, and this is what I have....

    <?php
    include '../../sql/dbcon.php';
    	$ip = $_SERVER['REMOTE_ADDR'];
    	$sessionip = $_SESSION['ip'];
    	$_SESSION['ip'] = $ip;
    	
         $count=0;
    	 $count=$count+1;
    	 $count++;
         
    	 
    	 echo $count." <b>Views</b>";
    
    $usql="update videos set Views=".$count;
    
    if($vidinfo[4] == $_SERVER["REQUEST_URI"]);
    {
    	if(!mysql_query($usql))
    	{
           echo mysql_errno().":";
           echo mysql_error();
    	}
    }
    
    ?>
    Code (markup):
    where the count ++ is, I want it to count views when ever someone comes on the page, like +1 for each view. The reason why I have the IP address is because im trying to do after each 5 minutes of someone's IP address, it can counts a view again, so people don't cheat.... so thats a problem too... I also tried mktime() function, but that didn't work, so I deleted it...

    Help please?
     
    Majo0od, Nov 8, 2009 IP
  6. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #6
    Have it place a cookie on there that expires in 5 minutes. Before adding check if the cookie exists. Or you could use sessions.
     
    Pudge1, Nov 8, 2009 IP
  7. Majo0od

    Majo0od Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    sessions are a lot better, because not all people enable cookies... sessions, every one has :D
     
    Majo0od, Nov 9, 2009 IP
  8. Deus Ex

    Deus Ex Peon

    Messages:
    531
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I third the sessions, add sessions by placing sessions in the middle of the code with the execute function
     
    Deus Ex, Nov 9, 2009 IP