Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Exercice 2
- //index.php
- function entete() {
- echo "<html>
- <body>
- <form action = 'verifUser.php' method = 'post'>
- <legend>Formulaire</legend>";
- }
- function champ_texte($nom, $etiq) {
- echo "$etiq : <input type = 'text' name = '$nom'> <br>";
- }
- function butt() {
- echo "<input type = 'Submit' name = 'Submit'> <br> ";
- }
- function ferm() {
- echo "</form>
- </body>
- </html>";
- }
- entete();
- champ_texte("user","Username");
- champ_texte("pass","Password");
- butt();
- ferm();
- ?>
- <?php
- //verifUser.php
- session_start();
- $user = $_POST["user"];
- $pass = $_POST["pass"];
- $con = mysqli_connect("localhost", "root", "","testBD");
- $req = "select * from utlisateur where username = $user and password = $pass";
- mysqli_query($con, $req);
- if($mysqli_affected_rows($con) != 0) {
- $_SESSION['user'] = $user;
- $_SESSION['pass'] = $pass;
- header("location : vente.php");
- }
- else {
- header("location : index.php");
- echo "username or password incorrecte";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement