Jump to content

mikeleege

New Members
  • Posts

    4
  • Joined

  • Last visited

mikeleege's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I totally understand that the house is on fire, I am perfectly aware of all the problems, and that is exactly what I want to build, why?, because of the nature of the application of the page it needs that!
  2. Hmm, why you guys all are complaining about stuff that I am the one who should worry about! I just wanted to know some specific things yet no one wants to help and instead complaining about what I didn't ask for help for! 1. The users are not entering any passwords or giving any of their personal information to register before logging, instead I am the one who will randomly generate passwords. 2. I am using this for a specific application where I just want to make sure 1 computer is used to access whatever page after the login page. 3. There is nothing valuable in that website but I want to make that because I just want to make that! If someone can tell me how to do what I asked for I will be really thankful.
  3. Well, thanks for your reply. This login interface isn't meant to be used in something critical, I understand the security issues, the page I am implementing will have no more than about 500 users who have no idea about programming but I want to make sure those users login from a single computer only. The website will have no useful information for anyone to invest 5 minutes to attempt hacking it.
  4. Hi guys, I am pretty new to PHP. I am building a login form where I need the user to login using username and password. The first time he login I need to acquire his IP address or MAC address to limit any future logins to the specific IP address or MAC address he initially logged in from. I used the below codes from online forums to do the normal login form but I don't know how to do the IP registration and check thing, can anyone please help? index.php <?php include('login.php'); // Includes Login Script if(isset($_SESSION['login_user'])){ header("location: profile.php"); } ?> <!DOCTYPE html> <html> <head> <title>Login Form in PHP with Session</title> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body> <div id="main"> <h1>PHP Login Session Example</h1> <div id="login"> <h2>Login Form</h2> <form action="" method="post"> <label>UserName :</label> <input id="name" name="username" placeholder="username" type="text"> <label>Password :</label> <input id="password" name="password" placeholder="**********" type="password"> <input name="submit" type="submit" value=" Login "> <span><?php echo $error; ?></span> </form> </div> </div> </body> </html> Login.php <?php session_start(); // Starting Session $error=''; // Variable To Store Error Message if (isset($_POST['submit'])) { if (empty($_POST['username']) || empty($_POST['password'])) { $error = "Username or Password is invalid"; } else { // Define $username and $password $username=$_POST['username']; $password=$_POST['password']; // Establishing Connection with Server by passing server_name, user_id and password as a parameter $connection = mysql_connect("localhost", "user", "pass"); // To protect MySQL injection for Security purpose $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); // Selecting Database $db = mysql_select_db("db", $connection); // SQL query to fetch information of registerd users and finds user match. $query = mysql_query("select * from login where password='$password' AND username='$username'", $connection); $rows = mysql_num_rows($query); if ($rows == 1) { $_SESSION['login_user']=$username; // Initializing Session header("location: profile.php"); // Redirecting To Other Page } else { $error = "Username or Password is invalid"; } mysql_close($connection); // Closing Connection } } ?> Logout.php <?php session_start(); if(session_destroy()) // Destroying All Sessions { header("Location: index.php"); // Redirecting To Home Page } ?> Profile.php <?php include('session.php'); ?> <!DOCTYPE html> <html> <head> <title>Your Home Page</title> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body> <div id="profile"> <b id="welcome">Welcome : <i><?php echo $login_session; ?></i></b> <b id="logout"><a href="logout.php">Log Out</a></b> </div> </body> </html> Session.php <?php // Establishing Connection with Server by passing server_name, user_id and password as a parameter $connection = mysql_connect("localhost", "user", "pass"); // Selecting Database $db = mysql_select_db("db", $connection); session_start();// Starting Session // Storing Session $user_check=$_SESSION['login_user']; // SQL Query To Fetch Complete Information Of User $ses_sql=mysql_query("select username from login where username='$user_check'", $connection); $row = mysql_fetch_assoc($ses_sql); $login_session =$row['username']; if(!isset($login_session)){ mysql_close($connection); // Closing Connection header('Location: index.php'); // Redirecting To Home Page } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.