Mon script PHP n'affiche rien

maha_0200 Messages postés 1 Date d'inscription lundi 13 mai 2019 Statut Membre Dernière intervention 13 mai 2019 - 13 mai 2019 à 05:18
Raul duke Messages postés 70 Date d'inscription vendredi 16 décembre 2005 Statut Membre Dernière intervention 17 mai 2019 - 17 mai 2019 à 16:20
Bonjour, Voilà je suis entrain de créer un formulaire "Login" dans lequel l'utilisateur (ici un admin...) saisit son username et son password, il clique ensuite sur le bouton login pour accéder au page d’accueil
Mon problème est lorsque je clique sur bouton "login" il n'affiche rien
voila mon code php :
<?php 

   $PARAM_hote='localhost';
   $PARAM_nom_bd='inscription';
   $PARAM_utilisateur='root';      
   $PARAM_mot_passe='';

  $bdd= new PDO('mysql:host='.$PARAM_hote.';dbname='.$PARAM_nom_bd , $PARAM_utilisateur, $PARAM_mot_passe,
    array(PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION));
 


if(isset($_POST['submit'])){
    
    $nom=$_POST['username'];
    $password=$_POST['password'];
    
    $sql="select * from auth where nom='".$nom."' AND password='".$password."' limit 1";
    
    $result=mysqli_query($bdd,$sql);
    
    if(!$result || mysqli_num_rows($result)==1){
        echo " You Have Successfully Logged in";
        exit();
    }
    else{
        echo " You Have Entered Incorrect Password";
        exit();
    }
        
}
?>

et voila mon code html :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  

  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <style type="text/css">
body {
  background-image: url("http://techdefencelabs.com/public/img/services/network-penetration.jpg");
  background-size: cover;
}

#container {
  width: 400px;
  margin-right: auto;
  margin-bottom: 0px;
  margin-left: auto;
  margin-top: 10%;
}

form {
  width: 100%;
  padding-top: 30px;
  padding-right: 30px;
  padding-bottom: 30px;
  padding-left: 30px;
  border-top-width: 1px;
  border-right-width: 1px;
  border-bottom-width: 1px;
  border-left-width: 1px;
  border-top-style: solid;
  border-right-style: solid;
  border-bottom-style: solid;
  border-left-style: solid;
  border-top-color: #f1f1f1;
  border-right-color: #f1f1f1;
  border-bottom-color: #f1f1f1;
  border-left-color: #f1f1f1;
  -moz-border-top-colors: none;
  border-top-colors: none;
  -moz-border-right-colors: none;
  border-right-colors: none;
  -moz-border-bottom-colors: none;
  border-bottom-colors: none;
  -moz-border-left-colors: none;
  border-left-colors: none;
  border-image-source: none;
  border-image-slice: 100% 100% 100% 100%;
  border-image-width: 1 1 1 1;
  border-image-outset: 0 0 0 0;
  border-image-repeat: stretch stretch;
  background-color: white;
  background-image: none;
  background-repeat: repeat;
  background-attachment: scroll;
  background-clip: border-box;
  background-origin: padding-box;
  background-position-x: 0%;
  background-position-y: 0%;
  background-size: auto auto;
box-shadow: 0px 0px 20px 0px rgba(0, 0, 0, 0.2), 0px 5px 5px 0px rgba(0, 0, 0, 0.24);
}

#container h1 {
  width: 38%;
  margin-top: 0px;
  margin-right: auto;
  margin-bottom: 0px;
  margin-left: auto;
  padding-bottom: 10px;
}

input[type="text"], input[type="password"] {
  width: 100%;
  padding-top: 12px;
  padding-right: 20px;
  padding-bottom: 12px;
  padding-left: 20px;
  margin-top: 8px;
  margin-right: 0px;
  margin-bottom: 8px;
  margin-left: 0px;
  display: inline-block;
  border-top-width: 1px;
  border-right-width: 1px;
  border-bottom-width: 1px;
  border-left-width: 1px;
  border-top-style: solid;
  border-right-style: solid;
  border-bottom-style: solid;
  border-left-style: solid;
  border-top-color: #cccccc;
  border-right-color: #cccccc;
  border-bottom-color: #cccccc;
  border-left-color: #cccccc;
  -moz-border-top-colors: none;
  border-top-colors: none;
  -moz-border-right-colors: none;
  border-right-colors: none;
  -moz-border-bottom-colors: none;
  border-bottom-colors: none;
  -moz-border-left-colors: none;
  border-left-colors: none;
  border-image-source: none;
  border-image-slice: 100% 100% 100% 100%;
  border-image-width: 1 1 1 1;
  border-image-outset: 0 0 0 0;
  border-image-repeat: stretch stretch;
  box-sizing: border-box;
}

input[type="submit"] {
  background-color: #53af57;
  color: white;
  padding-top: 14px;
  padding-right: 20px;
  padding-bottom: 14px;
  padding-left: 20px;
  margin-top: 8px;
  margin-right: 0px;
  margin-bottom: 8px;
  margin-left: 0px;
  border-top-width: medium;
  border-right-width: medium;
  border-bottom-width: medium;
  border-left-width: medium;
  border-top-style: none;
  border-right-style: none;
  border-bottom-style: none;
  border-left-style: none;
  border-top-color: currentcolor;
  border-right-color: currentcolor;
  border-bottom-color: currentcolor;
  border-left-color: currentcolor;
  -moz-border-top-colors: none;
  border-top-colors: none;
  -moz-border-right-colors: none;
  border-right-colors: none;
  -moz-border-bottom-colors: none;
  border-bottom-colors: none;
  -moz-border-left-colors: none;
  border-left-colors: none;
  border-image-source: none;
  border-image-slice: 100% 100% 100% 100%;
  border-image-width: 1 1 1 1;
  border-image-outset: 0 0 0 0;
  border-image-repeat: stretch stretch;
  cursor: pointer;
  width: 100%;
}

input[type="submit"]:hover {
  background-color: white;
  color: black ;
  border-top-width: 1px;
  border-right-width: 1px;
  border-bottom-width: 1px;
  border-left-width: 1px;
  border-top-style: solid;
  border-right-style: solid;
  border-bottom-style: solid;
  border-left-style: solid;
  border-top-color: #53af57;
  border-right-color: #53af57;
  border-bottom-color: #53af57;
  border-left-color: #53af57;
  -moz-border-top-colors: none;
  border-top-colors: none;
  -moz-border-right-colors: none;
  border-right-colors: none;
  -moz-border-bottom-colors: none;
  border-bottom-colors: none;
  -moz-border-left-colors: none;
  border-left-colors: none;
  border-image-source: none;
  border-image-slice: 100% 100% 100% 100%;
  border-image-width: 1 1 1 1;
  border-image-outset: 0 0 0 0;
  border-image-repeat: stretch stretch;
}

#maha {
  background-attachment: scroll;
  background-repeat: repeat repeat;
  background-origin: border-box;
  font-size: 100%;
  font-weight: bolder;
  font-style: normal;
  text-align: left;
}

</style>
  </head>
  <body >
  <div id="page" class="site">
      <div class="content-wrapper">
        <header id="page-header" class="page-header header-06 dark-logo-version">
          <div class="page-header-place-holder"></div>
          <div id="page-header-inner" class="page-header-inner" data-sticky="1">
            <div class="container">
              <div class="row">
                <div class="col-xs-12">
                  <div class="header-wrap">
                    <div class="branding">
                      <div class="branding__logo">  <img src="https://www.sotetel.tn/site/wp-content/uploads/2019/04/logo2.png"

                            alt="Sotetel" class="light-logo" style="width: 324px; height: 119px;">
                      </div>
                    </div>
                  </div>
                  <div class="container">
                    <!-- zone de connexion -->
                   <form  method="POST" action="connect.php" >
                      <h1>Connexion</h1>
                      <label> <b>Nom d'utilisateur</b></label> 
                      <div class="form-input">
                      <input placeholder="Entrer le nom d'utilisateur"

                        name="username" required="" type="text"></div>
                         <label> <b>Mot
                          de passe</b></label>
                          <div class="form-input">
                           <input placeholder="Entrer le mot de passe"

                        name="password" required="" type="password">
                        </div>

 <a href="http://localhost:8080/inscription/inscription.html">
                    <input id="submit" value="LOGIN" type="submit" http://localhost:8080/MAHA.html> 

                       </a >
                       
                  
      
                      <p></p>
                    </form>
                  
                  </div>
                  <p>                                                                                                               
                              
                           
                    <span style="color: white;"> 
                      <label></label></span>  
                      <span style="color: white;">
                             <b>Vous n'avez pas un compte</b>
                      </span>

                           <a href="http://localhost:8080/inscription/inscription.html">
                      <input id="submit" value="inscript" type="submit" onclick="http://localhost:8080/inscription.html"> </a> </p>
                </div>
              </div>
            </div>
          </div>
        </header>
      </div>
    </div>
  </body>
</html>

2 réponses

cs_eli42 Messages postés 143 Date d'inscription mardi 24 décembre 2002 Statut Membre Dernière intervention 11 juillet 2023 1
17 mai 2019 à 13:51
Salut Maha

Perso je fais tout sur la même page sauf la connexion à la base
Je me connecte en PDO mais c'est le même principe

alert('Beau temps belle mer');
Jorgio

<?php
   $erreur = '';
   if (isset($_POST['username'])) {
       if (isset($_POST['password'])) {       
           $username = $_POST['username'];
           $password = $_POST['password'];
           require_once("connexion_base.php");        
           $sql = $pdo->query("select * from reservation where EMAIL='" . $username . "'");
           $sql->setFetchMode(PDO::FETCH_OBJ);
           $data = $sql->fetch();
           if ($data) {
               $password = hash('sha512', 'phrasesecrete' . $password);            
               if ($data->PASS === $password) {                
                   echo '<script>window.onload = window.open("pagesuivante", "_top");</script>';
                   exit;                
               } else {
                   $erreur = 'Erreur identifiant';
               }            
               
           } else {
               $erreur = 'Utilisateur inconnue';
           }
       }
   }
?>
<style>
.classred{border:1px solid red}
</style>

<span id="resultat"><?php echo $erreur?></span>
<form name=connection action='' method=post>
   <input class="" name="username" type="text">
   <input class="" name="password" type="password">
</form>
<div onclick="_connect()">Valider</div>
<script>
   function _connect(){
    if(document.connection.username.value == ''){alert("Veuillez saisir l'identifiant.");document.connection.username.className = 'classred';document.connection.username.focus();return false}
    if(document.connection.password.value == ''){alert("Veuillez saisir le mot de passe.");document.connection.password.className = 'classred';document.connection.password.focus();return false}
    document.forms['connection'].action = 'connexion';document.forms['connection'].submit();return true;
    }
</script>


--
0
Raul duke Messages postés 70 Date d'inscription vendredi 16 décembre 2005 Statut Membre Dernière intervention 17 mai 2019 2
17 mai 2019 à 16:20
Tu l'a inclus dans ta page au moins le php ?
0
Rejoignez-nous