samedi 18 juin 2016

Need Some Java Script Popup / Modal Login In my script

  1. index.php page
<button type="reset" onclick="location.href='admin.php'">Log In</button>
  1. Redirected to loging.php Page
<?php
//..............Session & Validation
if($_POST){
    include 'configdb.php';
    $username=$_POST['username'];
    $password=$_POST['password'];
    $sUser=mysqli_real_escape_string($conn,$username);
    $sPass=mysqli_real_escape_string($conn,$password);
    $query="SELECT * FROM LOGIN_INFO WHERE USERNAME='$sUser' AND PASSWORD='$sPass'";
    $result=mysqli_query($conn,$query);
    if(mysqli_num_rows($result)==1){
        session_start();
        $_SESSION['anything']='something';
        header('location:admin.php');
    }
}
?>

Loging Form

<form method="post">
    <div class="header">
        <h1>WELCOME</h1>
    </div>
    <div class="banner-top">
        <h2>Log In / Sign Up</h2>
        <div class="banner-top" style="color: #fff">
            Username:<br><input type="text" name="username" placeholder="User Name" autocomplete="off"><br><br>
            Password:<br><input type="password" name="password" placeholder="*****"><br><br>
            <input type="submit" value="Log In">
            <button type="reset" onclick="location.href='signup.php'">Sign Up</button>
            <button type="reset" onclick="location.href='index.php'">Close</button>
        </div>
    </div>
</form>
  1. Redirected to admin.php Page

Working Great But need some JavaScript Popup, i'm beginner so need full Script, thanks in advanced Here is My Modal Login popup not getting database id n password for validation

<?php

include("config.php"); session_start();

if($_SERVER["REQUEST_METHOD"] == "POST") { // username and password sent from form

  $myusername = mysqli_real_escape_string($db,$_POST['username']);
  $mypassword = mysqli_real_escape_string($db,$_POST['password']); 

  $sql = "SELECT * FROM logg WHERE un = '$myusername' and pw = '$mypassword'";
  $result = mysql_query($query) or die ("Unable to verify user because " . mysql_error());
  $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
  $active = $row['active'];

  $count = mysqli_num_rows($result);

  // If result matched $myusername and $mypassword, table row must be 1 row

  if($count == 1) {
     session_register("myusername");
     $_SESSION['username'] = $myusername;

     header("Location: welcome.php");
  }else {
     $error = "Your Login Name or Password is invalid";
  }

} ?>

Aucun commentaire:

Enregistrer un commentaire