01net    Web


Actuellement en ligne : 308 Utilisateurs dont 15 dans Programmation et développement >S'inscrire      >S'identifier      >Recherche      >Aide  
modéré par A.Ouloube, Beno@  
01net > Forum de 01net > Programmation et développement > PHP
> Encore un bug php !
Passionné(e) d'internet, de logiciels, de forums ? 01net recrute...
Auteur
Message
 
<     1       >
matzik
  
   
      ?   @     Posté le 10/07/2007 13:30:50  
Voter pour ce message
J'ai un soucis avec mon script php et je ne trouve pas le problème... snif !
L'erreur se trouve à la dernière ligne !

Voila le script en entier :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Document sans titre</title>
</head>

<?php

if (isset($_POST['id'])) // Si la variable existe
{
// On se crée une variable $mot_de_passe avec le mot de passe entré
$id = $_POST['id'];
}
if (isset($_POST['passe'])) // Si la variable existe
{
// On se crée une variable $mot_de_passe avec le mot de passe entré
$passe = $_POST['passe'];
}
else // La variable n'existe pas encore
{
$passe = ""; // On crée une variable $mot_de_passe vide
}


if ($id == "Admin" AND $passe == "Pass") // Si le mot de passe est bon
{
// On affiche la page cachée.
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<meta name="generator" content="Adobe GoLive">
<title></title>
<style type="text/css">
<!--
.Style1 {
font-size: medium;
font-weight: bold;
}
-->
</style>
</head>

<body bgcolor="#ffffff">
<p align="center" class="Style1">Mairie de Lalouvesc :</p>
<p align="center" class="Style1">Mise &agrave; Jour de votre Gadget Lalouvesc.com</p>
<p align="center"> </p>

<form name="form1" method="post" action="Mairie/ecrivain.php">
<label>
<div align="center">Titre du message :
<input type="text" name="titre" id="titre">
<br>
<br>
Taper votre message :<br>
<textarea name="text" id="text" cols="100" rows="15"></textarea>
</div>
</label>
<p align="center">
<label>
<input type="submit" name="Envoyer" id="Envoyer" value="Envoyer">
</label>
</p>
<p align="center">&nbsp;</p>
<p align="center"><a href="Update finale/Suppression.php">/!\ Supprimer tous les messages pr&eacute;c&eacute;dents /!\</a></p>
</form>
</body>

</html>
<?php
if ($id == "Admin2" AND $passe == "Passe2") // Si le mot de passe est bon
{
// On affiche la page cachée.
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<meta name="generator" content="Adobe GoLive">
<title></title>
<style type="text/css">
<!--
.Style1 {
font-size: medium;
font-weight: bold;
}
-->
</style>
</head>

<body bgcolor="#ffffff">
<p align="center" class="Style1">Office du tourisme :</p>
<p align="center" class="Style1">Mise &agrave; Jour de votre Gadget Lalouvesc.com</p>
<p align="center"> </p>

<form name="form1" method="post" action="OT/ecrivain.php">
<label>
<div align="center">Titre du message :
<input type="text" name="titre" id="titre">
<br>
<br>
Taper votre message :<br>
<textarea name="text" id="text" cols="100" rows="15"></textarea>
</div>
</label>
<p align="center">
<label>
<input type="submit" name="Envoyer" id="Envoyer" value="Envoyer">
</label>
</p>
<p align="center">&nbsp;</p>
<p align="center"><a href="Update finale/Suppression.php">/!\ Supprimer tous les messages pr&eacute;c&eacute;dents /!\</a></p>
</form>
</body>

</html>
<?php
if ($id == "Admin3" AND $passe == "Passe3") // Si le mot de passe est bon
{
// On affiche la page cachée.
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<meta name="generator" content="Adobe GoLive">
<title></title>
<style type="text/css">
<!--
.Style1 {
font-size: medium;
font-weight: bold;
}
-->
</style>
</head>

<body bgcolor="#ffffff">
<p align="center" class="Style1">Lalouvesc.com:</p>
<p align="center" class="Style1">Mise &agrave; Jour de votre Gadget Lalouvesc.com</p>
<p align="center"> </p>

<form name="form1" method="post" action="OT/ecrivain.php">
<label>
<div align="center">Titre du message :
<input type="text" name="titre" id="titre">
<br>
<br>
Taper votre message :<br>
<textarea name="text" id="text" cols="100" rows="15"></textarea>
</div>
</label>
<p align="center">
<label>
<input type="submit" name="Envoyer" id="Envoyer" value="Envoyer">
</label>
</p>
<p align="center">&nbsp;</p>
<p align="center"><a href="Update finale/Suppression.php">/!\ Supprimer tous les messages pr&eacute;c&eacute;dents /!\</a></p>
</form>
</body>

</html>

<?php
}

else // le mot de passe n'est pas bon
{
// On affiche la zone de texte pour rentrer le mot de passe.
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<title>Mot de passe incorrect !</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>

<!-- ImageReady Slices (Update.psd) -->
<table id="Tableau_01" width="993" height="334" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><img src="../images/Update_01.png" width="25" height="1" alt=""></td>
<td colspan="7" rowspan="2"><img src="../images/Update_02.png" width="941" height="31" alt=""></td>
<td rowspan="2"><img src="../images/Update_03.png" width="26" height="31" alt=""></td>
<td><img src="../images/spacer.gif" width="1" height="1" alt=""></td>
</tr>
<tr>
<td><img src="../images/Update_04.png" width="25" height="30" alt=""></td>
<td><img src="../images/spacer.gif" width="1" height="30" alt=""></td>
</tr>
<tr>
<td><img src="../images/Update_05.png" width="25" height="102" alt=""></td>
<td><img src="../images/Update_06.png" width="111" height="102" alt=""></td>
<td><img src="../images/Update_07.png" width="105" height="102" alt=""></td>
<td><img src="../images/Update_08.png" width="114" height="102" alt=""></td>
<td><img src="../images/Update_09.png" width="107" height="102" alt=""></td>
<td rowspan="2"><img src="../images/Update_10.png" width="248" height="103" alt=""></td>
<td><img src="../images/Update_11.png" width="1" height="102" alt=""></td>
<td rowspan="2"><img src="../images/Update_12.png" width="255" height="103" alt=""></td>
<td><img src="../images/Update_13.png" width="26" height="102" alt=""></td>
<td><img src="../images/spacer.gif" width="1" height="102" alt=""></td>
</tr>
<tr>
<td rowspan="2"><img src="../images/Update_14.png" width="25" height="27" alt=""></td>
<td colspan="4" rowspan="2"><img src="../images/Update_15.png" width="437" height="27" alt=""></td>
<td rowspan="2"><img src="../images/Update_16.png" width="1" height="27" alt=""></td>
<td rowspan="2"><img src="../images/Update_17.png" width="26" height="27" alt=""></td>
<td><img src="../images/spacer.gif" width="1" height="1" alt=""></td>
</tr>
<tr>
<td><img src="../images/Update_18.png" width="248" height="26" alt=""></td>
<td><img src="../images/Update_19.png" width="255" height="26" alt=""></td>
<td><img src="../images/spacer.gif" width="1" height="26" alt=""></td>
</tr>
<tr>
<td background="../images/Update_20.png"> </td>
<td colspan="7" bgcolor="#bdffb4"><div>
<form name="form1" method="post" action="secu.php">
<fieldset>
<legend>Authentification : </legend>
<table width="367" border="0" align="center">
<tr>
<td width="174">Identifiant : </td>
<td width="183"><label>
<input type="text" name="id" id="id">
</label></td>
</tr>
<tr>
<td><label>Mot de passe :

</label></td>
<td><input type="text" name="passe" id="passe"></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Envoyer" id="Envoyer" value="Envoyer">
</div></td>
</tr>
</table>
</fieldset>
</form>
</div>
<div align="center">L'authentification a &eacute;chou&eacute;e : mauvais codes d'acc&egrave;s !</div></td>
<td background="../images/Update_22.png"> </td>
<td><img src="../images/spacer.gif" width="1" height="169" alt=""></td>
</tr>
<tr>
<td><img src="../images/Update_23.png" width="25" height="5" alt=""></td>
<td colspan="7"><img src="../images/Update_24.png" width="941" height="5" alt=""></td>
<td><img src="../images/Update_25.png" width="26" height="5" alt=""></td>
<td><img src="../images/spacer.gif" width="1" height="5" alt=""></td>
</tr>
</table>
<!-- End ImageReady Slices -->

</body>
</html>

<?php

} // Fin du else

// Fin du code :)
?>
Beno@
  
  :-)
      ?   @     Posté le 10/07/2007 14:50:30  
Voter pour ce message
tu oublie de fermer au moins un if il me semble ;)

enf ait a chaque fois que tu met un nouveau if pour fficher une page selon l'utilisateur et le mot de passe tu oublie de fermer tes if ;)

d'ailleurs, si tu pourrais faire comme cela:

if ($id=="1" && $passe=="1")
{
// on affiche la page 1
}
elseif
($id=="2" && $passe=="2")
{
// on affiche la page 2
}
elseif
($id=="3" && $passe=="3")
{
// on affiche la page 3
}
else

{
// on affiche la zone de texte
}


"elseif" pourrait dire sinon si

ca fait:
si c'est l'utilisateur 1, alors on affiche la page 1;
sinon, si c'est l'utilisateur 2, alors on affiche la page 2;
sinon, si c'est l'utilisateur 3, alors on affiche la page 3;
sinon, on affiche le formulaire

-->Message édité par Beno@ le 10/07/2007 15:01:01<--
matzik
  
   
      ?   @     Posté le 11/07/2007 12:57:26  
Voter pour ce message
Merci je vais essayer ca tout de suite
matzik
  
   
      ?   @     Posté le 11/07/2007 13:12:23  
Voter pour ce message
Bon, j'ai tenté une simplification de mon script pour y voir plus clair :

<?php
// J'ai choisi le mot de passe "kangourou"

if (isset($_POST['id'])) // Si la variable existe
{
// On se crée une variable $mot_de_passe avec le mot de passe entré
$id = $_POST['id'];
}
if (isset($_POST['passe'])) // Si la variable existe
{
// On se crée une variable $mot_de_passe avec le mot de passe entré
$passe = $_POST['passe'];
}
else // La variable n'existe pas encore
{
$passe = ""; // On crée une variable $mot_de_passe vide
}
?>
<?php

if ($id == "Admin1" AND $passe == "Passe1")
{
echo "Admin";
}

elseif ($id == "Admin2" AND $passe == "Passe2")
{
echo "Admin2";
}

elseif ($id == "Admin3" AND $passe == "Passe3") //
{
echo "Passe";
}

else // SINON (la variable ne contient ni Oui ni Non, on ne peut pas agir)
{
echo "erreur ! Problème d'identification";
}
?>

Et j'obtiens les erreurs suivantes :

Notice: Undefined variable: id in c:\users\matthieu\documents\lalouvesc.com\lalouvesc\web-content\beta\update\update finale\secu.php on line 23

Notice: Undefined variable: id in c:\users\matthieu\documents\lalouvesc.com\lalouvesc\web-content\beta\update\update finale\secu.php on line 28

Notice: Undefined variable: id in c:\users\matthieu\documents\lalouvesc.com\lalouvesc\web-content\beta\update\update finale\secu.php on line 33
erreur ! Problème d'identification
matzik
  
   
      ?   @     Posté le 11/07/2007 14:34:11  
Voter pour ce message
J'ai rien dit ! Tout beigne !
Beno@
  
  :-)
      ?   @     Posté le 11/07/2007 19:58:18  
Voter pour ce message
:)
<     1       >

01net > Forum de 01net > Programmation et développement > PHP
> Encore un bug php !

Aller à :

Page générée en : 0.107s - X2board 2.2

Nous contacter | Charte de confiance | Voir notice légale

Tous droits réservés © 1999 - 2008 Groupe Tests - 01net.


Sites du réseau 01net Network : 01net - 01men - Rmc.fr - Bfmtv.fr - Radiobfm.com - TousLesPodcasts - Micro Achat

Sarkozy en Vel Satis
Une Renault Vel Satis truffée d'équipement high tech pour le Président sarkozy le 14 juillet.
Astuces
Trucs et Astuces : tous les matchs de l'Euro 2008 dans votre calendrier et sur votre bureau !