Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- login.php
- ----------------------------------------------------------------------------
- <?php
- // Always start this first
- session_start();
- if ( ! empty( $_POST ) ) {
- if ( isset( $_POST['username'] ) && isset( $_POST['password'] ) ) {
- $user = $_POST['username'];
- $pass = $_POST['password'];
- $servername = "localhost";
- $username = "aristons";
- $password = "hyrasxgraz65!";
- $dbname = "aristons_programmazione";
- $link = new mysqli($servername, $username, $password, $dbname);
- $sqlricerca = "SELECT * FROM login WHERE username = '$user'";
- //echo $sqlricerca;
- $rispsw = mysqli_query($link,$sqlricerca);
- $numrows = mysqli_num_rows($rispsw);
- if ($numrows>0){
- while($psr = $rispsw->fetch_assoc()){
- $pswdb = $psr['pass'];
- $id = $psr['id'];
- }
- }else{
- echo "username non trovato";
- }
- $passmd5 = md5($pass);
- // Verify user password and set $_SESSION
- if ($passmd5 == $pswdb ) {
- $_SESSION['user_id'] = $id;
- }
- }
- }
- ?>
- index.php // tutte le pagine
- -------------------------------------
- <?php
- include('login.php'); // Includes Login Script
- if(isset($_SESSION['user_id'])){
- header("location: /home.php");
- }
- ?>
- <?php
- include('login.php'); // Includes Login Script
- if(isset($_SESSION['user_id'])){
- header("location: /home.php");
- }
- ?>
- <link rel="stylesheet" type="text/css" href="/cssagg.css">
- <!DOCTYPE html>
- <html>
- <body>
- <div class="contenuto">
- <div class="logoariston"><img src="http://www.aristonsanremo.com/wp-content/uploads/2015/09/Logo-Ariston2.png" width="200"></div>
- <center><br><br><br>
- <form action="" method="post">
- <label>USER :</label>
- <input id="name" name="username" placeholder="username" type="text"><br>
- <label>PASSWORD :</label>
- <input id="password" name="password" placeholder="**********" type="password"><br><br>
- <input name="submit" type="submit" value=" Login ">
- </form>
- </center>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement