1
I wanted to make a div that only appears to some portion of people who access my site, how do I do this?
1
I wanted to make a div that only appears to some portion of people who access my site, how do I do this?
3
If it is for example based on a user being logged in could be done this way:
I divide my page into small php files (with pure HTML elements) and check if the user is logged in if yes the page will be composed with a logout button if not with login and registration buttons.
session_start();
if((!isset($_SESSION['email']) == true) and (!isset($_SESSION['pass']) == true)){
require_once 'components/modals/login-modal.php';
require_once 'components/modals/create-account-modal.php';
}else{
require_once 'components/modals/logout-modal.php';
}
This way the Divs will be segmented
It is also possible to segregate based on other requirements such as the user’s browser:
<?php
$useragent = $_SERVER['HTTP_USER_AGENT'];
if (preg_match('|MSIE ([0-9].[0-9]{1,2})|',$useragent,$matched)) {
$browser_version=$matched[1];
$browser = 'IE';
} elseif (preg_match( '|Opera/([0-9].[0-9]{1,2})|',$useragent,$matched)) {
$browser_version=$matched[1];
$browser = 'Opera';
} elseif(preg_match('|Firefox/([0-9\.]+)|',$useragent,$matched)) {
$browser_version=$matched[1];
$browser = 'Firefox';
} elseif(preg_match('|Chrome/([0-9\.]+)|',$useragent,$matched)) {
$browser_version=$matched[1];
$browser = 'Chrome';
} elseif(preg_match('|Safari/([0-9\.]+)|',$useragent,$matched)) {
$browser_version=$matched[1];
$browser = 'Safari';
} else {
$browser_version = 0;
$browser= 'other';
}
?>
<html>
<head>
<title></title>
</head>
<body>
<?php
if($browser == 'Safari'){
echo '<span id="#internal">Safari</span>';
}else{
echo '<span>Outro navegador</span>';
}
?>
</body>
</html>
Based on the string contained in $_SERVER['HTTP_USER_AGENT']
(Super Global) it is possible to identify by comparison of strings which Browser, Version and even OS (in some cases).
It’s because I’m making a website and I want to advertise, but the site will only have about one page and I want to put my own form of advertising, and in case in the future the site will have several advertising requests, so I wanted to make a system that would do for example like "20% of the people who access this advertisement,other twenty will see another advertisement".
@Luvinicius, what would be the criterion to achieve this 20% (place, age, sex...). Even by default, these 20%
would be based on the total of previous accesses - I believe it is the simplest estimate to apply.
But there is no way to "draw" the 20% that will see the advertisement?
Browser other questions tagged php html
You are not signed in. Login or sign up in order to post.
What is the criterion of segregation?
– Ricardo
You need guarantees that people don’t access this or just a facilitator to hide what should not be seen?
– Maniero
I need it to be like a draw of who will see the ad.
– Luvinicius