daily pastebin goal
56%
SHARE
TWEET

Untitled

a guest Sep 24th, 2016 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. signin page
  2.  
  3. include('login.php'); // Includes Login Script
  4.  
  5. if(isset($_SESSION['login_user'])){
  6. header("location: myaccount.php");
  7. }
  8.  
  9. ...
  10.  
  11. <p class="details">
  12.              Login or create and Account
  13.              <?php echo $error; ?>
  14.             </p>
  15.            
  16.                 <div class="contact_form">
  17.                 <div class="form_subtitle">login into your account</div>
  18.                  <form name="Login" method="POST">          
  19.                     <div class="form_row">
  20.                     <label class="contact"><strong>Username:</strong></label>
  21.                     <input id="name" name="username" placeholder="username" type="text">
  22.                     </div>  
  23.  
  24.  
  25.                     <div class="form_row">
  26.                     <label class="contact"><strong>Password:</strong></label>
  27.                     <input id="password" name="password" placeholder="**********" type="password">
  28.                     </div>
  29.  
  30. //end of signin page
  31.  
  32. start of login.php
  33.  
  34. session_start(); // Starting Session
  35. $error=''; // Variable To Store Error Message
  36. if (isset($_POST['submit'])) {
  37. if (empty($_POST['username']) || empty($_POST['password'])) {
  38. $error = "Username or Password is invalid";
  39. }
  40. else
  41. {
  42. // Define $username and $password
  43. $username=$_POST['username'];
  44. $password=$_POST['password'];
  45. $errors = array();
  46.  
  47.     if ((strlen($username) == 0) || (strlen($password) == 0)){
  48.         array_push($errors, "You must enter a valid username and Password");
  49.     }
  50. // Establishing Connection with Server by passing server_name, user_id and password as a parameter
  51.         $query = "SELECT COUNT(*) AS NUMBER_OF_ROWS FROM ( SELECT * FROM users WHERE Username  = '$username' AND Password = '$password' )";
  52.  
  53. //skip connection details
  54.  
  55. $stmt = oci_parse($connect, $query);
  56. if(!$stmt) {
  57.         echo "An error occurred in parsing the sql string.\n";
  58.         exit;
  59.         }
  60. oci_define_by_name($stmt, 'NUMBER_OF_ROWS', $rows);
  61. oci_execute($stmt);
  62. oci_fetch($stmt);
  63.  
  64. if ($rows == 1) {
  65.     $error = "You have successfully logged in";
  66.     $query ="SELECT ROW FROM users WHERE Username  = '$username' AND Password = '$password'";
  67.     $stmt = oci_parse($connect, $query);
  68.     oci_execute($stmt);
  69.     $_SESSION['login_user']=$username; // Initializing Session
  70. header("location: myaccount.php"); // Redirecting To Other Page
  71. } else {
  72. $error = "Username or Password is invalid" . $row;
  73. }
  74.  // Closing Connection
  75. }
  76. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top