Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- login.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'];
- $errors = array();
- if ((strlen($username) == 0) || (strlen($password) == 0)){
- array_push($errors, "You must enter a valid username and Password");
- }
- // Establishing Connection with Server by passing server_name, user_id and password as a parameter
- $query = "SELECT COUNT(*) AS NUMBER_OF_ROWS FROM ( SELECT * FROM users WHERE Username = '$username' AND Password = '$password' )";
- //$query ="SELECT * FROM users WHERE Username = '$username' AND Password = '$password'";
- ...//connection stuff
- // SQL query to fetch information of registerd users and finds user match.
- $stmt = oci_parse($connect, $query);
- if(!$stmt) {
- echo "An error occurred in parsing the sql string.\n";
- exit;
- }
- oci_define_by_name($stmt, 'NUMBER_OF_ROWS', $rows);
- oci_execute($stmt);
- oci_fetch($stmt);
- if ($rows == 1) {
- $error = "You have successfully logged in";
- $query ="SELECT ROW FROM users WHERE Username = '$username' AND Password = '$password'";
- $stmt = oci_parse($connect, $query);
- oci_execute($stmt);
- $_SESSION['login_user']=$username; // Initializing Session
- header("location: myaccount.php"); // Redirecting To Other Page
- } else {
- $error = "Username or Password is invalid" . $row;
- }
- // Closing Connection
- }
- }
- end login.php
- signin.php
- include('login.php'); // Includes Login Script
- if(isset($_SESSION['login_user'])){
- header("location: myaccount.php");
- }
- ...
- <p class="details">
- Login or create and Account
- <?php echo $error; ?>
- </p>
- <div class="contact_form">
- <div class="form_subtitle">login into your account</div>
- <form name="Login" method="POST">
- <div class="form_row">
- <label class="contact"><strong>Username:</strong></label>
- <input id="name" name="username" placeholder="username" type="text">
- </div>
- <div class="form_row">
- <label class="contact"><strong>Password:</strong></label>
- <input id="password" name="password" placeholder="**********" type="password">
- </div>
- <!--<div class="form_row">
- <div class="terms">
- <input type="checkbox" name="terms" />
- Remember me
- </div>
- </div> -->
- <div class="form_row">
- <input name="submit" type="submit" class="Login" value="login" />
- </div>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement