I have searched for this issue but all solution in javaScript related. I need to check a button is clicked or not. Button (<a href="something"></a>
) is also link to other page. I have tried but my code is working for when anyone view that page. I want when anyone click on view button. My Code:
$for_linking = preg_replace(array('/\.[A-Z]*/i') , '', $orders->order_file);
if (isset($_GET['link'])) {
$link = $_GET['link'];
if($_SERVER['PHP_SELF'] == $for_linking){
$ip_address = gethostbyname(trim(`hostname`));
$pc_username = getenv("username");
DB::table('click_counts')->insertGetId([
'ip' => $ip_address,
'username' => $pc_username,
'order_id' => $orders->id,
]);
}
}
return '<a href="' . url("file").'/'.$orders->order_file.'/?link='.$for_linking.'" class="btn btn-xs btn-primary">View</a>';
I have used datatable to show the data. If i don't use if
condition then data is inserting when i page viewed. But i want when anyone click on View
then data will be inserted. So i can i use if condition here?
Below Code is work for just view page:
$ip_address = gethostbyname(trim(`hostname`));
$pc_username = getenv("username");
DB::table('click_counts')->insertGetId([
'ip' => $ip_address,
'username' => $pc_username,
'order_id' => $orders->id,
]);
return '<a href="' . url("file").'/'.$orders->order_file.'" class="btn btn-xs btn-primary">View</a>';
Table: