Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['login-form'])) {
- // Your Code Here
- }
- ?>
- <html>
- <body>
- <form action=<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?> method="post" enctype="multipart/form-data" >
- Name: <input type="text" name="name"><br>
- E-mail: <input type="text" name="email"><br>
- <button type="submit" name="login-form"> Submit </button>
- </form>
- <?php
- include('base.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'];
- $username = stripslashes($username);
- $password = stripslashes($password);
- $username = mysql_real_escape_string($username);
- $password = mysql_real_escape_string($password);
- // Selecting Database
- $db = mysql_select_db("company", $connection); //$connection -> Connection of the database from base.php
- // Assuming you have table LOGIN or Change the table name with your along with the database columns
- // 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 to check whether the user is logged in or not in another pages
- $_SESSION['login_user'] = $username; // Initializing Session
- header("location: PageYouWantAfterLogin.php"); // Redirecting To Other Page
- } else {
- $error = "Username or Password is invalid";
- }
- mysql_close($connection); // Closing Connection
- }
- }
- ?>
- <input type="text" name="username" class="user" value="Tu Correo Electrónico" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Tu Correo Electrónico';}"/>
- <input type="password" name="password" class="lock" value="password" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Email address:';}"/>
- <input name="submit" type="submit" value=" Login ">
- <form action="" method="post">
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement