integration d'une fonction message
salut tout le monde
j'ai intégré une fonction message sur mon script et ça fonctionne pas si quelqu'un peut m'aider à résoudre ce petit soucis ça sera génial
j'ai 2 pages:
_cnx.php
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| <?php
function connexion() {
$host = 'localhost'; //Votre host, souvent localhost
$user = 'root'; //votre login
$pass = ''; //Votre mot de passe
$db = 'test'; // Le nom de la base de donnee
mysql_connect ($host,$user,$pass) or die ('Erreur : '.mysql_error());
mysql_select_db($db) or die ('Erreur :'.mysql_error());
}
function message($msg)
{
$code="<script language=\"javascript\" type=\"text/javascript\">";
$code.="alert('$msg')";
$code.="</script>";
echo $code;
}
?> |
index.php
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| <!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>Untitled Document</title>
</head>
<body>
<form name="form1" method="post" action="">
<table width="100%" border="1">
<tr>
<td width="50%">matricule</td>
<td width="50%"><label for="matricule"></label>
<input type="password" name="matricule" id="matricule"></td>
</tr>
<tr>
<td>Mot de passe</td>
<td><label for="mot de passe"></label>
<input type="password" name="passe" id="passe"></td>
</tr>
</table>
<div style="text-align: center"> <input type="submit" name="button" id="button" value="S'authentifier">
<input type="reset" name="button2" id="button2" value="Effacer">
</div>
</form>
</body>
</html>
<?php
include ('config/_cnx.php');
connexion();
if(isset($_POST['matricule'])) {
$matricule = $_POST['matricule'];
$passe = $_POST['passe'];
$sql="SELECT destination FROM membre where matricule='".$_POST['matricule']."' and passe='".$_POST['passe']."'";
$r= mysql_query($sql);
while($ligne=mysql_fetch_array($r))
{
if(empty($matricule) and empty($passe) and $matricule!=$ligne['matricule'] and $passe!=$ligne['passe'] )
{
message('matricule ou mot de passe incorrect');
header ('location: index.php');
}
$dest=$ligne['destination'];
header("Location:$dest");
}
}
?> |
je compte sur vous