September 3, 200520 yr Bonjour. J'aimerais connaitre le "script" en php qui permet d'accéder directement à une page internet : du style pour le html : <a href="http://www.pcinpact.com">PCI</a> mais la pour le php : if ($pass == "xxx") -amène sur pcinpact- else {echo "ERREUR";} Merci Edited September 3, 200520 yr by x-per
September 3, 200520 yr if ($pass == "xxx") { echo "<a href=\"http://www.pcinpact.com\">PCI</a>"; } else { echo "ERREUR"; } Sinon si tu veux une redirection, tu peux le faire avec la fonction PHP header, mais ca marche seulement si tu n'as rien envoyé au navigateur avant (pas de echo) : header('Location: mapage.html'); ou bien sinon en javascript.
September 3, 200520 yr Author Merci Ishiro, mais en fait voila, j'ai du mal m'exprimer donc tu va tout comprendre à ma question par cet exemple : Si, lorsque je rentre le pass "xxx", je veux accéder directement à Google. Donc d'après toi je met : if ($pass == "xxx") {header ('Location: http://www.google.fr');} else {echo "<center><font color=red><b>ERREUR</b></font></center>";} Pourtant sa ne marche pas ...
September 4, 200520 yr Author Je met : if ($pass == "xxx") {header ('location: http://www.google.fr');} else {echo "<center><font color=red><b>ERREUR</b></font></center>";} et il me répond : Warning: Cannot modify header information - headers already sent by (output started at c:\program files\Wamp\www\parts.php: in c:\program files\Wamp\www\parts.php on line 12
September 4, 200520 yr lorsque tu met un header tu ne doit avoir aucune sortie ecran avant ni aucun caractere html sur ta la page la tu as en ligne 8 dans part 8 un echo ou un truc dans le style ensuite apres un header met toujours un exit(); if ($pass == "xxx") {header ('location: http://www.google.fr'); exit();} else {echo "<center><font color=red><b>ERREUR</b></font></center>";}
September 4, 200520 yr Et dans le cas où tu peux pas passer par un header, tu as toujours la solution JavaScript (Mieux vaut faire autrement si c'est possible) : if ($pass == "xxx") { echo "<script type=\text/javascript\">window.location='http://www.pcinpact.com'</script>"; } else { echo "ERREUR"; }
Archived
This topic is now archived and is closed to further replies.