Php aidé moi
Utilisateur anonyme
-
Giglagla Messages postés 32 Date d'inscription Statut Membre Dernière intervention -
Giglagla Messages postés 32 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
j'ai un probléme
voila mon code php
index.php
<?
session_start();
session_destroy();
$message=""
$Login=$_POST['Login'];
if($Login){
$username=$_POST['username'];
$md5_password=md5($_POST['password']);
$host="localhost";
$db_user="root";
$db_password="";
$database="tutorial";
mysql_connect($host,$db_user,$db_password) or die('Erreur de connexion '.mysql_error());
mysql_select_db($database) or die('Erreur de selection '.mysql_error());
$result=mysql_query("select * from admin where username='$username' and password='$md5_password'");
mysql_query($result) or die('Erreur SQL !'.$result.'<br>'.mysql_error());
if(mysql_num_rows($result)!='0'){
session_register("username");
header("location:main.php");
exit; sortie;
}
else
{
$message="--- Incorrect Username or Password ---";
}
}
?>
<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>
<? echo $message; ?>
<form id="form1" name="form1" method="post" action="<? echo $_SERVER['PHP_SELF']?>">
<table>
<tr>
<td><input name="Login" type="submit" id="Login" value="Login" /></td>
<td> utilisateur: </ td>
<td><input name="username" type="text" id="username" /></td>
<td> Mot de passe: </ td>
<td><input name="password" type="password" id="password" /></td>
</tr>
</table>
</form>
</body>
</html>
et le main.php
<?
session_start();
if(!session_is_registered("username")){
header("location:index.php");
}
?>
<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>
<p> Bonjour <? echo $_SESSION['username']; ?> Vous êtes maintenant connecté </ p>
<p><a href="index.php">Logout</a></p>
</body>
</html>
a chaque foi si j'éxécute ca me renvoi une érreur
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at c:\program files\easyphp1-8\www\exercice\mysql\index.php:2) in c:\program files\easyphp1-8\www\exercice\mysql\index.php on line 3
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at c:\program files\easyphp1-8\www\exercice\mysql\index.php:2) in c:\program files\easyphp1-8\www\exercice\mysql\index.php on line 3
Notice: Undefined variable: Login in c:\program files\easyphp1-8\www\exercice\mysql\index.php on line 10
j'ai un probléme
voila mon code php
index.php
<?
session_start();
session_destroy();
$message=""
$Login=$_POST['Login'];
if($Login){
$username=$_POST['username'];
$md5_password=md5($_POST['password']);
$host="localhost";
$db_user="root";
$db_password="";
$database="tutorial";
mysql_connect($host,$db_user,$db_password) or die('Erreur de connexion '.mysql_error());
mysql_select_db($database) or die('Erreur de selection '.mysql_error());
$result=mysql_query("select * from admin where username='$username' and password='$md5_password'");
mysql_query($result) or die('Erreur SQL !'.$result.'<br>'.mysql_error());
if(mysql_num_rows($result)!='0'){
session_register("username");
header("location:main.php");
exit; sortie;
}
else
{
$message="--- Incorrect Username or Password ---";
}
}
?>
<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>
<? echo $message; ?>
<form id="form1" name="form1" method="post" action="<? echo $_SERVER['PHP_SELF']?>">
<table>
<tr>
<td><input name="Login" type="submit" id="Login" value="Login" /></td>
<td> utilisateur: </ td>
<td><input name="username" type="text" id="username" /></td>
<td> Mot de passe: </ td>
<td><input name="password" type="password" id="password" /></td>
</tr>
</table>
</form>
</body>
</html>
et le main.php
<?
session_start();
if(!session_is_registered("username")){
header("location:index.php");
}
?>
<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>
<p> Bonjour <? echo $_SESSION['username']; ?> Vous êtes maintenant connecté </ p>
<p><a href="index.php">Logout</a></p>
</body>
</html>
a chaque foi si j'éxécute ca me renvoi une érreur
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at c:\program files\easyphp1-8\www\exercice\mysql\index.php:2) in c:\program files\easyphp1-8\www\exercice\mysql\index.php on line 3
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at c:\program files\easyphp1-8\www\exercice\mysql\index.php:2) in c:\program files\easyphp1-8\www\exercice\mysql\index.php on line 3
Notice: Undefined variable: Login in c:\program files\easyphp1-8\www\exercice\mysql\index.php on line 10
A voir également:
- Php aidé moi
- Easy php - Télécharger - Divers Web & Internet
- Expert php pinterest - Télécharger - Langages
- Retour a la ligne php - Forum Webmastering
- Alert php - Forum PHP
- Retour a la ligne php ✓ - Forum PHP