Rotation de liens en PHP
Résolu
redploplop
Messages postés
45
Date d'inscription
Statut
Membre
Dernière intervention
-
redploplop Messages postés 45 Date d'inscription Statut Membre Dernière intervention -
redploplop Messages postés 45 Date d'inscription Statut Membre Dernière intervention -
Bonsoir .
Alors je chercher el code source d'une page en PHP permettant de changé d'URL à chaque clic
Exemple: je clic sur www.exemple.com/out.php qui me redirige vers www.redirection1.com
et si je Re-clic sur www.exemple.com/out.php il me redirigera vers un autre site .....
Voilà merci d'avance
Alors je chercher el code source d'une page en PHP permettant de changé d'URL à chaque clic
Exemple: je clic sur www.exemple.com/out.php qui me redirige vers www.redirection1.com
et si je Re-clic sur www.exemple.com/out.php il me redirigera vers un autre site .....
Voilà merci d'avance
A voir également:
- Rotation de liens en PHP
- Rotation ecran windows - Guide
- Rotation video - Guide
- Vérificateur de liens - Guide
- Easy php - Télécharger - Divers Web & Internet
- Expert php pinterest - Télécharger - Langages
6 réponses
<?php $liste_site = array('site1','site2','site3',etc...); shuffle($liste_site); header('Location: '.$liste_site[0]); ?>
ça évite pas mal de code inutile :)
es ce que ce code correspond a ce que tu voulai?
<?php
if(isset($_GET["redirection"])){
$nb_min = 0;
$nb_max = 3;
$nombre = mt_rand($nb_min,$nb_max);
echo $nombre."<br/>";
switch($nombre){
case 0:
echo "redirection 0 google<br/>";
header('Location: http://www.google.fr');
break;
case 1:
echo "redirection 1 Forum CCM<br/>";
header('Location: https://forums.commentcamarche.net/forum/
break;
case 2:
echo "redirection 2 yahoo<br/>";
header('Location: https://fr.yahoo.com/
break;
case 3:
echo "redirection 3 pole emploi<br/>";
header('Location: https://www.pole-emploi.fr/accueil/
break;
}
}
?>
<html>
<head>
</head>
<body>
<a href="redirectionAutreSite.php?redirection=1">redirections</a>
</body>
</html>
<?php
if(isset($_GET["redirection"])){
$nb_min = 0;
$nb_max = 3;
$nombre = mt_rand($nb_min,$nb_max);
echo $nombre."<br/>";
switch($nombre){
case 0:
echo "redirection 0 google<br/>";
header('Location: http://www.google.fr');
break;
case 1:
echo "redirection 1 Forum CCM<br/>";
header('Location: https://forums.commentcamarche.net/forum/
break;
case 2:
echo "redirection 2 yahoo<br/>";
header('Location: https://fr.yahoo.com/
break;
case 3:
echo "redirection 3 pole emploi<br/>";
header('Location: https://www.pole-emploi.fr/accueil/
break;
}
}
?>
<html>
<head>
</head>
<body>
<a href="redirectionAutreSite.php?redirection=1">redirections</a>
</body>
</html>
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
<?php
session_start();
$nb_min = 0;
$nb_max = 3;
$nombre = mt_rand($nb_min,$nb_max);
if(isset($_SESSION['URL'])){
if (intval($_SESSION['URL']) ==$nombre){
$nombre = $nombre+1;
}
}
if($nombre > 3){
$nombre=1;
}
if($nombre < 0){
$nombre=2;
}
echo $nombre."<br/>";
switch($nombre){
case 0:
echo "redirection 0 google<br/>";
$url = 'http://www.google.fr';
$_SESSION['URL']="0";
break;
case 1:
echo "redirection 1 Forum CCM<br/>";
$url = 'http://www.commentcamarche.net/forum/';
$_SESSION['URL']="1";
break;
case 2:
echo "redirection 2 yahoo<br/>";
$url = 'http://fr.yahoo.com/';
$_SESSION['URL']="2";
break;
case 3:
echo "redirection 3 pole emploi<br/>";
$url = 'http://www.pole-emploi.fr/accueil/';
$_SESSION['URL']="3";
break;
}
?>
<html>
<head>
</head>
<body>
<a href="<?php echo $url ; ?>">redirections</a>
</body>
</html>
session_start();
$nb_min = 0;
$nb_max = 3;
$nombre = mt_rand($nb_min,$nb_max);
if(isset($_SESSION['URL'])){
if (intval($_SESSION['URL']) ==$nombre){
$nombre = $nombre+1;
}
}
if($nombre > 3){
$nombre=1;
}
if($nombre < 0){
$nombre=2;
}
echo $nombre."<br/>";
switch($nombre){
case 0:
echo "redirection 0 google<br/>";
$url = 'http://www.google.fr';
$_SESSION['URL']="0";
break;
case 1:
echo "redirection 1 Forum CCM<br/>";
$url = 'http://www.commentcamarche.net/forum/';
$_SESSION['URL']="1";
break;
case 2:
echo "redirection 2 yahoo<br/>";
$url = 'http://fr.yahoo.com/';
$_SESSION['URL']="2";
break;
case 3:
echo "redirection 3 pole emploi<br/>";
$url = 'http://www.pole-emploi.fr/accueil/';
$_SESSION['URL']="3";
break;
}
?>
<html>
<head>
</head>
<body>
<a href="<?php echo $url ; ?>">redirections</a>
</body>
</html>
MERCI infiniment
Dans le genre ^^