Erreur PHP Notice: Undefined index: userid
saif.m
-
saif.m Messages postés 4 Statut Membre -
saif.m Messages postés 4 Statut Membre -
Bonjour, je vous présente mon problème.
j'ai crée mon premier forum en php et dant la page de connection des membres (login.php),mais lorsque je fait une exécution de la page l'erreur suivant se maffiche:
Notice: Undefined index: user in /opt/lampp/htdocs/saif/login.php on line 102
Notice: Undefined index: user in /opt/lampp/htdocs/saif/login.php on line 102
Notice: Undefined index: username in /opt/lampp/htdocs/saif/login.php on line 110
*a la ligne 102 il ya ceci:
*et a la ligne 110 il y a ceci:
si vous pouvez m'aider s.v.p. :)
le code du "login.php" est:
j'ai crée mon premier forum en php et dant la page de connection des membres (login.php),mais lorsque je fait une exécution de la page l'erreur suivant se maffiche:
Notice: Undefined index: user in /opt/lampp/htdocs/saif/login.php on line 102
Notice: Undefined index: user in /opt/lampp/htdocs/saif/login.php on line 102
Notice: Undefined index: username in /opt/lampp/htdocs/saif/login.php on line 110
*a la ligne 102 il ya ceci:
$nb_new_pm = mysql_fetch_array(mysql_query('select count(*) as nb_new_pm from pm where ((user1="'.$_SESSION['userid'].'" and user1read="no") or (user2="'.$_SESSION['userid'].'" and user2read="no")) and id2="1"'));
*et a la ligne 110 il y a ceci:
<a href="list_pm.php">Vos messages(<?php echo $nb_new_pm; ?>)</a> - <a href="profile.php?id=<?php echo $_SESSION['userid']; ?>"><?php echo htmlentities($_SESSION['username'], ENT_QUOTES, 'UTF-8'); ?></a> (<a href="login.php">Déconnexion</a>)
si vous pouvez m'aider s.v.p. :)
le code du "login.php" est:
<?php
//Cette page permet aux utilisateurs de se connecter ou de se deconnecter
include('config.php');
if(isset($_SESSION['username']))
{
unset($_SESSION['username'], $_SESSION['userid']);
setcookie('username', '', time()-100);
setcookie('password', '', time()-100);
?>
<!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" />
<link href="<?php echo $design; ?>/style.css" rel="stylesheet" title="Style" />
<title>Connexion</title>
</head>
<body>
<div class="header">
<a href="<?php echo $url_home; ?>"><img src="<?php echo $design; ?>/images/logo.png" alt="Espace Membre" /></a>
</div>
<div class="message">Vous avez bien été déconnecté.<br />
<a href="<?php echo $url_home; ?>">Accueil</a></div>
<?php
}
else
{
$ousername = '';
if(isset($_POST['username'], $_POST['password']))
{
if(get_magic_quotes_gpc())
{
$ousername = stripslashes($_POST['username']);
$username = mysql_real_escape_string(stripslashes($_POST['username']));
$password = stripslashes($_POST['password']);
}
else
{
$username = mysql_real_escape_string($_POST['username']);
$password = $_POST['password'];
}
$req = mysql_query('select password,id from users where username="'.$username.'"');
$dn = mysql_fetch_array($req);
if($dn['password']==$password and mysql_num_rows($req)>0)
{
$form = false;
$_SESSION['username'] = $_POST['username'];
$_SESSION['userid'] = $dn['id'];
if(isset($_POST['memorize']) and $_POST['memorize']=='yes')
{
$one_year = time()+(60*60*24*365);
setcookie('username', $_POST['username'], $one_year);
setcookie('password', sha1($password), $one_year);
}
?>
<!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" />
<link href="<?php echo $design; ?>/style.css" rel="stylesheet" title="Style" />
<title>Connexion</title>
</head>
<body>
<div class="header">
<a href="<?php echo $url_home; ?>"><img src="<?php echo $design; ?>/images/logo.png" alt="Espace Membre" /></a>
</div>
<div class="message">Vous avez bien été connecté. Vous pouvez accéder à votre espace membre.<br />
<a href="<?php echo $url_home; ?>">Accueil</a></div>
<?php
}
else
{
$form = true;
$message = 'La combinaison que vous avez entré n\'est pas bonne.';
}
}
else
{
$form = true;
}
if($form)
{
?>
<!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" />
<link href="<?php echo $design; ?>/style.css" rel="stylesheet" title="Style" />
<title>Connexion</title>
</head>
<body>
<div class="header">
<a href="<?php echo $url_home; ?>"><img src="<?php echo $design; ?>/images/logo.png" alt="Espace Membre" /></a>
</div>
<?php
if(isset($message))
{
echo '<div class="message">'.$message.'</div>';
}
?>
<div class="content">
<?php
$nb_new_pm = mysql_fetch_array(mysql_query('select count(*) as nb_new_pm from pm where ((user1="'.$_SESSION['userid'].'" and user1read="no") or (user2="'.$_SESSION['userid'].'" and user2read="no")) and id2="1"'));
$nb_new_pm = $nb_new_pm['nb_new_pm'];
?>
<div class="box">
<div class="box_left">
<a href="<?php echo $url_home; ?>">Index du Forum</a> > Connexion
</div>
<div class="box_right">
<a href="list_pm.php">Vos messages(<?php echo $nb_new_pm; ?>)</a> - <a href="profile.php?id=<?php echo $_SESSION['userid']; ?>"><?php echo htmlentities($_SESSION['username'], ENT_QUOTES, 'UTF-8'); ?></a> (<a href="login.php">Déconnexion</a>)
</div>
<div class="clean"></div>
</div>
<form action="login.php" method="post">
Veuillez entrer vos identifiants pour vous connecter:<br />
<div class="login">
<label for="username">Nom d'utilisateur</label><input type="text" name="username" id="username" value="<?php echo htmlentities($ousername, ENT_QUOTES, 'UTF-8'); ?>" /><br />
<label for="password">Mot de passe</label><input type="password" name="password" id="password" /><br />
<label for="memorize">Se souvenir</label><input type="checkbox" name="memorize" id="memorize" value="yes" /><br />
<input type="submit" value="Connection" />
</div>
</form>
</div>
<?php
}
}
?>
<div class="foot"><a href="https://www.mackage.com/eu/en/craftsmanship">Simple PHP Forum Script</a> - <a href="https://www.mackage.com/eu/en/craftsmanship">Mnasri</a></div>
</body>
</html>
A voir également:
- Erreur PHP Notice: Undefined index: userid
- Notice gratuite - Guide
- Notice télécommande universelle grundig - Forum Téléviseurs
- Homday x-pert écouteur bluetooth notice ✓ - Forum Casque et écouteurs
- Expert php pinterest - Télécharger - Langages
- Erreur 3000 france tv - Forum Lecteurs et supports vidéo