SHARE
TWEET

Untitled

amine99 Sep 10th, 2019 (edited) 164 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.     //Exercice 2
  3.     //index.php
  4.     function entete() {
  5.         echo "<html>
  6.                 <body>
  7.                     <form action = 'verifUser.php' method = 'post'>
  8.                         <legend>Formulaire</legend>";
  9.     }
  10.     function champ_texte($nom, $etiq) {
  11.         echo "$etiq : <input type = 'text' name = '$nom'> <br>";
  12.     }
  13.     function butt() {
  14.         echo "<input type = 'Submit' name = 'Submit'> <br> ";
  15.     }
  16.     function ferm() {
  17.         echo "</form>
  18.                 </body>
  19.                     </html>";
  20.     }
  21.     entete();
  22.     champ_texte("user","Username");
  23.     champ_texte("pass","Password");
  24.     butt();
  25.     ferm();
  26. ?>
  27.  
  28.  
  29. <?php
  30.     //verifUser.php
  31.     session_start();
  32.     $user = $_POST["user"];
  33.     $pass = $_POST["pass"];
  34.     $con = mysqli_connect("localhost", "root", "","testBD");
  35.     $req = "select * from utlisateur where username = $user and password = $pass";
  36.     mysqli_query($con, $req);
  37.     if($mysqli_affected_rows($con) != 0) {
  38.         $_SESSION['user'] = $user;
  39.         $_SESSION['pass'] = $pass;
  40.         header("location : vente.php");
  41.     }
  42.     else {
  43.         header("location : index.php");
  44.         echo "username or password incorrecte";
  45.     }
  46. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top